Error when removing an event while it is being triggered
Closed this issue · 0 comments
aaronholsonege commented
An error occurs when calling EventBus.off
for an event that is currently firing. The following example will throw an error:
var callback1 = function() {
EventBus.off('test', callback1);
// ...
};
var callback2 = function() {
// ...
};
EventBus
.on('test', callback1)
.on('test', callback2)
.trigger('test');
This is happening because the event stack array is being modified while it is being looped through.