Closed hswolff closed 7 years ago
"all" event handlers are triggered after individual event handlers. That is to say, if you trigger "foo" the sequence of event handlers called is: "foo" -> all event handlers (which can include additional triggers) -> "all" -> event handlers. When you .off('all') within an event handler Backbone reassigns the "all" array of handlers such that when you get to triggering the "all" event handlers that array has not been updated. This is the line that reassigns that array: https://github.com/jashkenas/backbone/blob/bd50e2e4a4af5c09bc490185aab215794d42258b/backbone.js#L296 So that when you get here https://github.com/jashkenas/backbone/blob/bd50e2e4a4af5c09bc490185aab215794d42258b/backbone.js#L357 the "allEvents" value is stale.
"all" event handlers are triggered after individual event handlers. That is to say, if you trigger "foo" the sequence of event handlers called is: "foo" -> all event handlers (which can include additional triggers) -> "all" -> event handlers. When you .off('all') within an event handler Backbone reassigns the "all" array of handlers such that when you get to triggering the "all" event handlers that array has not been updated. This is the line that reassigns that array: https://github.com/jashkenas/backbone/blob/bd50e2e4a4af5c09bc490185aab215794d42258b/backbone.js#L296 So that when you get here https://github.com/jashkenas/backbone/blob/bd50e2e4a4af5c09bc490185aab215794d42258b/backbone.js#L357 the "allEvents" value is stale.