Join Slack
I'm trying to make a multiplatform WeakrefMap, but for some reason WeakRef/WeakMap is not available ...
# multiplatform
m
martmists
09/20/2023, 8:38 PM
I'm trying to make a multiplatform WeakrefMap, but for some reason WeakRef/WeakMap is not available on the JS target. What can I do instead?
e
ephemient
09/20/2023, 8:48 PM
the
WeakRef proposal for JS
was only accepted for ES12 and Kotlin/JS still targets ES5, so you can't really do anything (in a cross-platform safe way)
m
martmists
09/20/2023, 10:37 PM
But isn't it already available in every browser and nodejs?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
e
ephemient
09/20/2023, 11:13 PM
Kotlin/JS isn't up to date with the latest JS standards
ephemient
09/20/2023, 11:14 PM
https://youtrack.jetbrains.com/issue/KT-8373/JS-support-ES6-as-compilation-target
m
martmists
09/21/2023, 7:52 AM
I see, so there's currently no way to have a weakmap equivalent in Kotlin/JS?
c
CLOVIS
09/12/2024, 5:39 PM
In case anyone searches for this in the future, it's been added to the
kotlin-js
module in the official Kotlin Wrappers I made a multiplatform wrapper:
https://opensavvy.gitlab.io/groundwork/pedestal/api-docs/weak/index.html
(discussion in
#C078Z1QRHL3
)
3
Views
Open in Slack
Previous
Next
kotlinlang
A modern programming language that makes developers happier.
Powered by