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

Attaching a listener to the same event more than once will only be called at most once #8

Open
dashed opened this issue Dec 26, 2015 · 0 comments
Labels

Comments

@dashed
Copy link
Owner

dashed commented Dec 26, 2015

The listener instance is used as a path marker for Immutable.Map for optimal deletions (i.e. O(1)). Thus, attaching a listener to the same event more than once will only be called at most once.


A fix is as follows:

Create ref counter wrapping the listener function. This tracks how many times the listener has been attached to the same event and same keyPath. If ref wrapper exists, increment the counter.

Locate listener, and decrement ref counter. If counter == 0, delete the path from listeners map.

Unwrap ref wrapper and call listener up to N times.

@dashed dashed added the bug label Jan 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant