Replies: 1 comment 2 replies
-
No strong opinion on it yet :) Could you elaborate a bit more on the semantics here. I imagine:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In Canva, we have been finding it useful to have observable weak map, that is the observable equivalent of JavaScript
WeakMap
. This is useful because we can put an object as key there and never worry about the object would leak from the map, while keeping its content observable in a similar way as observable map (that adding / deleting / changing values can trigger reactions that is observing the given key).It is different from an observable map with
onBecomeUnobserved
orcreateTransformer
in the sense that it doesn't require anything to observe it in order to keep the value around.This would provide more parity with native JavaScript data structures, but I can also see reasons we may not want it in MobX:
Given these, it would be good to know whether the maintainers of MobX are interested in having observable weak map (and possibly also observable weak set) into MobX. Internally, we already implemented it using an additional
WeakMap<K, IAtom>
which is very straightforward with the exactly same interface asWeakMap
. But I can see it is more involved for it to be implemented as part of MobX with all the additional features, so even though I could contribute an implementation, I wouldn't put too much effort into it without consent from project maintainers.Beta Was this translation helpful? Give feedback.
All reactions