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

DS.change is emitted on an instance multiple times after only 1 modification #229

Closed
kabalage opened this issue Sep 30, 2015 · 2 comments
Closed
Assignees

Comments

@kabalage
Copy link

If I have n instances of a resource and modify one of them, DS.change is emitted n times on that one instance. Here's a plnkr.

@kabalage
Copy link
Author

As I see now, every callback given to data.on('DS.change', function(resource, data) { /*...*/ } is called with the modified data even if the data that changed is not the one it listens on. Updated the plnkr above to show the problem better.

The reason I want to listen on every instance separately is because I want to DSSave() them on change debounced independently.

@jmdobry
Copy link
Member

jmdobry commented Oct 3, 2015

The problem appears to be the implementation of Events that's being used. Events is mixed into the prototype of instance contructors, but doesn't correctly maintain a map of listeners, instead holding all listeners in one object, and therefore executing them all...

@jmdobry jmdobry added the bug label Oct 3, 2015
@jmdobry jmdobry self-assigned this Oct 3, 2015
@jmdobry jmdobry added the done label Oct 3, 2015
@jmdobry jmdobry closed this as completed in 8d8fc9e Oct 3, 2015
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