Skip to content

Commit

Permalink
Merge pull request #41 from h3llfyre/master
Browse files Browse the repository at this point in the history
fix error in foreach due to splice
  • Loading branch information
gilgen authored Aug 17, 2016
2 parents 2b10b2e + 5d628ba commit 2127bf2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions addon/services/pusher.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,15 @@ export default Ember.Service.extend({
if(typeof eventsToUnwire === 'string') {
eventsToUnwire = [eventsToUnwire];
}

eventBindings.forEach((binding, index) => {
let index = eventBindings.length;
while (index--){
let binding = eventBindings[index];
if(eventsToUnwire && !eventsToUnwire.contains(binding.eventName)) {
return;
}
channel.unbind(binding.eventName, binding.handler);
eventBindings.splice(index, 1);
});
}

if (Ember.isEmpty(eventBindings)) {
delete bindings[channelName].eventBindings[targetId];
Expand Down

0 comments on commit 2127bf2

Please sign in to comment.