In Kotlin/JS javascript arrays are represented as ...
# webassembly
r
In Kotlin/JS javascript arrays are represented as
Array<T>
, with
size
property (Kotlin syntax). In Kotlin/Wasm, JS arrays are represented as
JsArray<T>
, with
length
property (JS syntax). This makes writing code compatible with both targets (e.g. in common target) very hard at least. I've come up with some hacks based on expect/actual and dirty casts. Anyone has better ideas how to deal with this?
b
cc @Svyatoslav Kuzmich [JB]
Could you please provide more information why and how do you need JS Array
r
In this case I try to use browser Drag and Drop API.
org.w3c.dom.DataTransfer.types
is an array
I just need to check the values.
It's trivial in Kotlin/JS, fairly easy in Kotlin/Wasm, but hard to do with the same code because of length/size property.
s
Expect/actuals with casts is probably the best approach to commonise this for now. Ideally we’d want to have
JsArray<T>
and Wasm version of DOM API common between Kotlin/JS and Kotlin/Wasm, but the design is still in flux.