Is there a faster way to create a js object yet, or is
js("{}")
and then manually populating it with data still the most convenient?
c
Chenn
02/18/2020, 8:28 AM
Copy code
val obj: dynamic = object{}
reducers.forEach { obj[it.key] = it.value}
This is how I do it, but I have no clue about the difference in speed..
k
Kabbura
02/18/2020, 1:55 PM
You can use the
json()
function
Kabbura
02/18/2020, 1:55 PM
for example
Copy code
json(
"tooltip" to json(
"trigger" to "axis"
),
"xAxis" to json(
"data" to xAxisData
)
)
s
spierce7
02/18/2020, 2:04 PM
That looks super expensive. I see 6 short lived objects created from that
spierce7
02/18/2020, 2:05 PM
I mean super expensive in comparison to doing it natively. Does the compiler optimize those object creations away?
g
gbaldeck
02/18/2020, 8:50 PM
just do js("{}") and make an external interface so you can cast it and use it like a normal object
gbaldeck
02/18/2020, 8:53 PM
if your worried about optimization that is probably the quickest, but i doubt if either of the other two methods mentioned will have any noticeable impact on speed.