jussi.kalliokoski at gmail.com
Sun Nov 8 11:44:56 UTC 2015
On Sun, 8 Nov 2015 at 13:29 Nelo Mitranim <me at mitranim.com> wrote:
> 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.
I think I may have miscommunicated my meaning here. In the idea I've been
working on, the view has no subscription (except at top level) that can
push data to it, so there's nothing to unsubscribe from. The idea being
that the data structures are modeled purely synchronously (current version
+ diff to previous version). The reason for needing reference counting is
different from FRP streams: making sure resources can be collected instead
of leaving an infinite trail. So basically FRP in this comparison is a push
model that needs reference counting to free the leaf nodes whereas the
model I have in mind is pull where the reference counting is needed to free
the root nodes.
P.S. Thanks for the demo, will check it out!
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss