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

Removing event handlers fails if method names are used. #4171

Closed
gramster opened this issue Jul 20, 2012 · 2 comments
Closed

Removing event handlers fails if method names are used. #4171

gramster opened this issue Jul 20, 2012 · 2 comments
Assignees
Labels
closed-duplicate Closed in favor of an existing report

Comments

@gramster
Copy link
Contributor

If you have this:

   void foo(e) {}
   window.on.message.add(foo);
   window.on.message.remove(foo);

the handler will not get removed. Apparently thjis is because a new closure is created with each parameter reference to the method foo, so they are not seen as the same thing.

OTOH this works:

   void bar(e) {}
   var foo = bar;
   window.on.message.add(foo);
   window.on.message.remove(foo);

It would be good if this was fixed, and if not possible, then it should be clearly documented as it is real gotcha.

@DartBot
Copy link

DartBot commented Jul 21, 2012

This comment was originally written by ladicek@gmail.com


Isn't this a duplicate of issue #144?

@vsmenon
Copy link
Member

vsmenon commented Jul 23, 2012

Thanks, ladicek. Merging into 144.


Added Duplicate label.
Marked as being merged into #144.

@gramster gramster added Type-Defect closed-duplicate Closed in favor of an existing report labels Jul 23, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

3 participants