Remove `.call()` in EventDispatcher
See original GitHub issueContext
EventDispatcher currently use the .call()
to execute their callbacks, this causes some problems because the this
is being replaced in the callback context with the Event’s target as this
Proposal
- Replace these 2 sections of code with a simple callback to even
this._handlers[eventName][i].call(target, event);
// to
this._handlers[eventName][i](event);
and
handler.call(ev.target, ev);
// to
handler(ev);
- New unit tests required to ensure the “handlers”
this
is as expected in both paths
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
removeListener | EventDispatcher.php | Drupal 8.2.x
public function EventDispatcher::removeListener ... Removes an event listener from the specified events. ... 1 call to EventDispatcher::removeListener().
Read more >The EventDispatcher Component (Symfony Docs)
The Symfony EventDispatcher component implements the Mediator and Observer ... A call to the dispatcher's addListener() method associates any valid PHP ...
Read more >EventDispatcher - OpenTok.js | Vonage Video API Developer
(When you use the on() method to add an event handler, the handler is not removed when it is called.) The once() method...
Read more >openfl.events.IEventDispatcher - API Reference
When you no longer need an event listener, remove it by calling EventDispatcher.removeEventListener() ; otherwise, memory problems might result.
Read more >Cannot call method from the event dispatcher thread [duplicate]
I'm writing a program that records user mouse movement and clicks, and the plays them using the Robot class. I am running into...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @eonarheim, yep why not!?
Hi @nidble, good point this does introduce a breaking change, which will be okay for the v0.26 release. This change should be added it to the breaking changes section of the changelog.
Let me know if you are still open to working this issue, since the scope has increased from what we originally thought. This will require some refactoring of tests and possibly other engine code that is relying on the previous behavior.