Reference counting
Opened this issue · 3 comments
theronic commented
;) When will we see some reference counting for subscribe/unsubcribe, or is this project just languishing under a full-time employed closed source owner??
I want to do this in Reagent:
(defn user-list-component []
(let [users (mr/subscribe root [:users])]
(fn []
(for [u @users]
[:span (:username u)]))))
Thinking just going to fork and rewrite in Scala.
Jesus, Chris. Get on it. 👍 🎱
crisptrutski commented
Pull requests welcome 😝
crisptrutski commented
To clarify what's being asked for - reuse of repeated listeners and removal of stale ones, to deliver zero-fuss re-frame
subscriptions
crisptrutski commented
So here's how I understand the degree to which we could take this:
- Interface which caches
(r)atoms
bound to refs. - Interface to track "disposal" of subscriptions, and kill atom cache when 0 users
- Some kind of sugar to use (1) and (2) with lifecycle hooks in Reagent components
- Reuse existing
(r)atoms
that include given ref (ie.users
andusers/0
) via lens/cursor into the larger one. - Prune "nested" subscriptions when "parent" subscriptions are added.
- Prune "parent" subscriptions when only lense subscriptions remain (ie. if watching
users
, then watchingusers/0
), and reinstate the nested subscriptions.
Sounds like you just want (1)-(3)?
Not sure if (5) and (6) are even good ideas (can construct cases where they hurt more than help).
Would this still be a big win for you?