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

Fix issue with listeners not being cleaned up in alt' #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/manifold/deferred.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1115,10 +1115,16 @@
(success-error-unrealized x
val (success! d val)
err (error! d err)
(do (on-realized (chain' x)
#(success! d %)
#(error! d %))
(recur (inc i))))
(let [l (listener #(success! d %)
#(error! d %))]
(add-listener! x l)
(on-realized d
(fn [&args]
(cancel-listener! x l))
(fn [&args]
(cancel-listener! x l)))
Comment on lines +1122 to +1125
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solatis I would avoid doing [&args] here, since that's actually a valid symbol name. This will break if more than one arg is passed. Try something like [& _] instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if I'm not mistaken, a listener can be shared, so you can move its creation outside the loop and reuse it for each alternative.


(recur (inc i))))
(success! d x)))))
d))

Expand Down