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

Phaser.Signal.removeAll(context) removes all listeners regardless of the provided context #1168

Closed
alect opened this issue Sep 4, 2014 · 1 comment

Comments

@alect
Copy link

alect commented Sep 4, 2014

Simple to reproduce:

var listener = {};
function listenerFunc() {
}
game.onResume.add(listenerFunc, listener);
console.log(game.onResume.getNumListeners()); // Should log 3
game.onResume.removeAll(listener);
console.log(game.onResume.getNumListeners()); // Should log 2, but logs 0 instead.

The problem seems to be in line 260 of Signal.js.

this._bindings.length = 0;

With this line removed, the function seems to work as intended with a context, although I expect the intended behavior was something more like:

if (!context) {
    this._bindings.length = 0;
}
photonstorm added a commit that referenced this issue Sep 4, 2014
@photonstorm
Copy link
Collaborator

Thanks - well spotted! That must have been in there for ages too. Now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants