me at mitranim.com
Sun Nov 8 11:29:20 UTC 2015
I was just recently working on the same problem as Jussy: subscribe/unsubscribe pattern for view components, and immutable data tree for efficient updates.
(Working demo [here](https://github.com/Mitranim/chat); the subs/unsubs are completely implicit.)
Concluded that weakrefs offer no help with this whatsoever. In fact, they're a red herring. You always want to unsubscribe your listeners deterministically, exactly when the corresponding view is destroyed. Letting them hang around and attempt to update nonexistent views until the next GC phase is no good. In fact, React will give you warnings when you try to update unmounted components. It also provides the "will mount" / "will unmount" lifecycle methods to clean things up.
Pretty sure weakrefs are harmful rather than helpful in this particular use case. But I may have missed the point of the sentiment.
More information about the es-discuss