We should maybe have a Gradle plugin for making us...
# javascript
a
We should maybe have a Gradle plugin for making us able to use a lambda directly instead of calling
jso { }
on all the interfaces. It would only work when you also use kotlinx.wrappers in your project. I'm not sure if it is clear, do not hesitate to ask me questions to clarify it !
a
We already have a prototype for JS objects plugin like this:
Copy code
@JsSimpleObject
external interface User {
  val name: String
  val age: Int
  val status: String?
}

...

val user = User(name = "NAME", age = 22) /// status is optional, so, could be dropped
val updatedUser = user.copy(age = 23) // new object with the shape
I hope that It will be available in 2.0
I'm working on publishing it
a
Oooh this looks neat !
a
Under the hood, it will be a plain old JS-object
Copy code
var user = js("{ name: 'NAME', age: 22 }")
var updatedUser = Object.assign({}, user, { age: 23 })
K 1
As soon as it will be available - I will notify you all in this channel
👍 1
The only restriction - using the K2 compiler( Such a behavior is mostly impossible to implement with the K1 plugin API
And yes, just to mention, it will be a separated plugin
a
Ah, what new features from K2 are allowing that ?
a
Generating of top-level declarations
I create a top-level invoke-operator
But also, I remember I have a problem on adding it directly inside the companion-declaration
Need to check twice
a
Oh, that's great that it's now possible