-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
During event execution, stopListening call on another object does not prevent handler from executing #3466
Labels
Comments
We're actually discussing the cause of that behavior in #3463. |
jridgewell
added a commit
to jridgewell/backbone
that referenced
this issue
Feb 5, 2015
[js perf](http://jsperf.com/backbone-events-linked-list/18) Roughly equivalent performance. Using a linked list allows the events to be mutated by trigger, without skipping an event. This is a **breaking change**. Events used to use a linked list (and switched to an array in jashkenas#1284). But, it performed [very badly](http://jsperf.com/backbone-events-linked-list/8). I'm fairly certain that was due to [L106](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L106) recreating the linked list's object every `#on`, and [L138](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L138) calling `#on` to re-bind callbacks. This fixes jashkenas#3466 and closes jashkenas#3463.
jridgewell
added a commit
to jridgewell/backbone
that referenced
this issue
Feb 5, 2015
[js perf](http://jsperf.com/backbone-events-linked-list/18) Roughly equivalent performance. Using a linked list allows the events to be mutated by trigger, without skipping an event. This is a **breaking change**. Events used to use a linked list (and switched to an array in jashkenas#1284). But, it performed [very badly](http://jsperf.com/backbone-events-linked-list/8). I'm fairly certain that was due to [L106](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L106) recreating the linked list's object every `#on`, and [L138](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L138) calling `#on` to re-bind callbacks inside `#off`. This fixes jashkenas#3466 and closes jashkenas#3463.
jridgewell
added a commit
to jridgewell/backbone
that referenced
this issue
Feb 7, 2015
[js perf](http://jsperf.com/backbone-events-linked-list/18) Roughly equivalent performance. Using a linked list allows the events to be mutated by trigger, without skipping an event. This is a **breaking change**. Events used to use a linked list (and switched to an array in jashkenas#1284). But, it performed [very badly](http://jsperf.com/backbone-events-linked-list/8). I'm fairly certain that was due to [L106](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L106) recreating the linked list's object every `#on`, and [L138](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L138) calling `#on` to re-bind callbacks inside `#off`. This fixes jashkenas#3466 and closes jashkenas#3463.
jridgewell
added a commit
to jridgewell/backbone
that referenced
this issue
Feb 7, 2015
[js perf](http://jsperf.com/backbone-events-linked-list/18) Roughly equivalent performance. Using a linked list allows the events to be mutated by trigger, without skipping an event. This is a **breaking change**. Events used to use a linked list (and switched to an array in jashkenas#1284). But, it performed [very badly](http://jsperf.com/backbone-events-linked-list/8). I'm fairly certain that was due to [L106](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L106) recreating the linked list's object every `#on`, and [L138](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L138) calling `#on` to re-bind callbacks inside `#off`. This fixes jashkenas#3466 and closes jashkenas#3463.
jridgewell
added a commit
to jridgewell/backbone
that referenced
this issue
Mar 5, 2015
[js perf](http://jsperf.com/backbone-events-linked-list/18) Roughly equivalent performance. Using a linked list allows the events to be mutated by trigger, without skipping an event. This is a **breaking change**. Events used to use a linked list (and switched to an array in jashkenas#1284). But, it performed [very badly](http://jsperf.com/backbone-events-linked-list/8). I'm fairly certain that was due to [L106](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L106) recreating the linked list's object every `#on`, and [L138](https://github.com/jashkenas/backbone/blob/6c3d3838e10d5a070f0d1f604fb5c99ed34c8c93/backbone.js#L138) calling `#on` to re-bind callbacks inside `#off`. This fixes jashkenas#3466 and closes jashkenas#3463.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If there are two related objects listening to the same event, it appears that during event execution one object can not call stopListening on another object and prevent the handler callback during the same execution. Looks like the events get cached somewhere in the trigger and stopListening does not change that.
Let me illustrate with an example:
My expectation is that if parent handler is called first, the child alert should not come up. However both alerts are issued.
http://jsfiddle.net/8y4b1ruv/1/
Backbone.js 1.1.2
The text was updated successfully, but these errors were encountered: