-
Notifications
You must be signed in to change notification settings - Fork 126
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
derived-atom: remove watches on source atoms #94
Comments
Yes! A way to dispose derived-atom is surely needed. I think dispose is probably better than going manually to every source atom and unsubscribe the key. I was only thinking about statically-defined derived atoms (via top-level |
Finally had some time for this and ended up with a Would you be open to replace https://github.com/martinklepsch/derivatives/blob/master/src/org/martinklepsch/derived.cljc |
@martinklepsch So essentially we want to propagate |
That sounds about right, yes! |
Heyo, folks! Been curious about making derived-atoms lazy.
In the end, I managed to get the desired properties with this implementation (some tests down below there, as examples). All-in-all, wanted to share this with you folks, perhaps you may find it to be of use. @martinklepsch, thanks for this discussion and the link to the IDisposable version, been an inspiration. |
When using
derived-atom
a watch is added to all source atoms but there's no way to remove these watches potentially causing stale watches when the derived atom is no longer needed.I have a very rough implementation that extends the derived atom implementation by a
IDisposable
protocol which provides a method that will remove all relevant watches on source atoms:https://github.com/martinklepsch/derivatives/blob/disposable/src/org/martinklepsch/derived.cljc
Watching a derived atom is broken in this implementation because it's not an atom but that's easily fixable.
Now the question, would you be interested in extending Rum's derived atom to cover this aspect?
The text was updated successfully, but these errors were encountered: