GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
I stumbled upon line 222 of the ModelCollection.
//Clean in any case the listener for delete.
There is no method removeAllListeners() with two arguments. removeAllListeners() removes all listeners of the given type.
I think now is the time to go over our current classes and check if all listeners are removed properly. For every on(type, func) there should be at least one removeListener(type, func), maybe more. But the class should only remove those listeners that have been added by itself.
To accomplish this it's useful to search for occurences of on(. After that we have to trace all actions that make this binding between emitter and listener invalid. For instance dispose(). Or in the ModelCollection: The change event listener needs to be removed too when the model fires a delete event.
I'm assigning it to @topa, so he can refactor it. After that @meaku should go over his classes.
When applicable we should add a check to the unit test if all listeners have been removed.
- Fixed removeAllListeners (described in #103)
- Fixed bug when several models are removed via delete-event
I'll take care of these classes:
The DisplayObjects provides a method to bind events it node and node's sub-node. But the only possibility to remove this events is to call .dispose() or require the beloved domAdapter and use it's .off. I think we should provide an additional method on the DisplayObject for this.
@jhnns what do you think (new issue)?
- .undelegate() uses now removeListener instead of removeAllListeners #…
- ModelCollection's .dispose() isn't disposing Models anymore, but re…
…moves all listeners from itself and sets inner collection to null. #103
We may provide this in the future but for now it's not urgent.
If the developer wants to remove event listeners from DOM nodes he should use his DOM framework. The DisplayObject is only providing addNodeEvents because if the DisplayObject is disposed, all DOM events should be removed. We don't want to replace tasks that are usually done by a DOM framework.
- using now removeListener for undelegation onAdd #103
I'll leave this open. We should add unit tests for that.