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

The Signal class is missing a handy way to remove all bindings from a certain context. #880

Closed
lucbloom opened this issue Jun 5, 2014 · 3 comments

Comments

@lucbloom
Copy link
Contributor

lucbloom commented Jun 5, 2014

Phaser.Signal.prototype.removeAllWithContext: function (context) {
        for (var i = 0; i < this._bindings.length; ++i) {
            var b = this._bindings[i];
            if (b.context === context) {
                b._destroy();
                this._bindings.splice(i, 1);
            }
        }
    },

Then, in my game code I can do:

onSceneExit = function()
{
       this.game.onResize.removeAllWithContext(this);
}
photonstorm added a commit that referenced this issue Jul 3, 2014
… listeners matching the given context are removed (thanks @lucbloom for the idea, #880)
@photonstorm
Copy link
Collaborator

Nice idea, but I think easier to roll into existing removeAll as optional parameter.

@Phaiax
Copy link
Contributor

Phaiax commented Jul 3, 2014

I did't looked for the implication, but i noticed you were using once
destroy();
and once
_destroy();

@photonstorm
Copy link
Collaborator

Yes, fixed - I hate the code in the Signal class, it needs a total review imho - I'm sure it is causing slow-downs through-out Phaser.

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

3 participants