is there a kotlinjs equivalent of WeakReference?
# javascript
p
is there a kotlinjs equivalent of WeakReference?
k
There's no WeakReference in JavaScript, so we have no chance to implement it in Kotlin/JS
k
It's not WeakReference 🙂
p
But can be used to emulate one, right?
k
How?
p
Probably better with a
WeakSet
actually. Create one with one item. If it doesn't have it, it's gone? I haven't used it before, so not sure if that's possible.
k
I could not find any way to get object from WeakSet. The only operation it supports is to check whether object is in set. To perform such operation, you need to store reference to the object somewhere, which prevents this object from collecting by GC
p
Very true, there is no way to iterate the objects, how is that a set, hehe.
k
+2 years, since all users has to migrate to new browsers that support this feature
(or +7 years in case of enterprise)
p
So true, there isn't other mechanism to watch an object's references in JS, right?
k
I don't know of something like this