matterandvoid-space / subscriptions

A subscriptions library over a source of data (forked + extracted from re-frame)
Other
50 stars 1 forks source link

Fix caching subscriptions in react use-sub hook #31

Closed dvingo closed 1 year ago

dvingo commented 1 year ago

There was a bug:

The error was calling dispose! on unmount. The solution is to use reference counting, storing the counter on the subscription itself (this will be either a reagent.ratom.Reaction or reagent.ratom.Cursor). When the reference counter is zero it is safe to dispose of.