Is there a way to merge two `jso`? So lets say I ...
# javascript
h
Is there a way to merge two
jso
? So lets say I have
Copy code
external interface DemoProps: Props {
    var first: String
    var second: Int
}
In many JS examples they just do something along the lines of
Copy code
val jso1 = jso<DemoProps> { first = "hello" }
val jso2 = jso<DemoProps> { second = 42 }
val merged = jso1 + jso2
What works is
Copy code
val merged = jso1.apply { second = jso2.second }
but is there a way without adressing every field again? Edit: This works, but is a bit scetchy:
Copy code
val merged = js("{...jso1, ...jso2}") as DemoProps
t
Copy code
val merged = Object.assign(jso(), jso1, jso2)
h
Hey, thanks for the answer the js
spread
worked, but that looks better. Thanks.
Like a charm thank you.
Copy code
Object.assign(jso<AppDialogProps>(), preset, additional)
t
In common case
js
calls aren't recommended. For now all known problems can be solved without it (via Kotlin Wrappers).
h
Yeah I figured, but wasn't aware that the
Object.assign
wrapped this closely. 😄