Will <Weak References> to Kotlin objects be suppor...
# webassembly
d
Will Weak References to Kotlin objects be supported in the WASM target? They're an important mechanism for implementing some types of caches. Direct expect/actual to JS WeakRef will only bridge 'external, primitive, string and function types' which is too limiting. See: • WASM proposal for WeakRef support • Kotlin WeakReference type for Native • WeakReference type for JVM (inc. Kotlin)
4
a
Could I ask you to create an issue in YouTrack with this description? We'll take a look at what we could do with it.
👍 1
d
☝️ @jessewilson @PHondogo @Alexander Girke @Artem Kobzar
👍 3
🙏 1
thank you color 1
🙏🏻 1
s
Thanks for the report! Wasm GC does not have weak references yet, we have to go through JS.
Direct expect/actual to JS WeakRef will only bridge ‘external, primitive, string and function types’ which is too limiting.
You can use JsReference<T> to send any Kotlin object to JS and retrieve it back. An example of WeakReference implemented in wasmJs
d
Many thanks @Svyatoslav Kuzmich [JB] for taking the time to provide this 🙌 - I've added it as a 'workaround method' to the YouTrack ticket also.