Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference counting #52

Open
theronic opened this issue Feb 18, 2016 · 3 comments
Open

Reference counting #52

theronic opened this issue Feb 18, 2016 · 3 comments

Comments

@theronic
Copy link
Collaborator

;) 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
Copy link
Owner

Pull requests welcome 😝

@crisptrutski crisptrutski changed the title Abandoned? No reference counting Reference counting Mar 15, 2016
@crisptrutski
Copy link
Owner

To clarify what's being asked for - reuse of repeated listeners and removal of stale ones, to deliver zero-fuss re-frame subscriptions

@crisptrutski crisptrutski added this to the v0.1.0 milestone Mar 15, 2016
@crisptrutski
Copy link
Owner

So here's how I understand the degree to which we could take this:

  1. Interface which caches (r)atoms bound to refs.
  2. Interface to track "disposal" of subscriptions, and kill atom cache when 0 users
  3. Some kind of sugar to use (1) and (2) with lifecycle hooks in Reagent components
  4. Reuse existing (r)atoms that include given ref (ie. users andusers/0) via lens/cursor into the larger one.
  5. Prune "nested" subscriptions when "parent" subscriptions are added.
  6. Prune "parent" subscriptions when only lense subscriptions remain (ie. if watching users, then watching users/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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants