Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/ListenerMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ export default {
_.throwIf(this.validateListening(listenable));
this.fetchInitialState(listenable, defaultCallback);
desub = listenable.listen(this[callback] || callback, this);
unsubscriber = function() {
var index = subs.indexOf(subscriptionobj);
unsubscriber = function(listenerSubs) {
var currentSubs = listenerSubs ? listenerSubs : subs;
var index = currentSubs.indexOf(subscriptionobj);
_.throwIf(index === -1, "Tried to remove listen already gone from subscriptions list!");
subs.splice(index, 1);
currentSubs.splice(index, 1);
desub();
};
subscriptionobj = {
Expand All @@ -143,7 +144,7 @@ export default {
for(;i < subs.length; i++){
sub = subs[i];
if (sub.listenable === listenable){
sub.stop();
sub.stop(subs);
_.throwIf(subs.indexOf(sub) !== -1, "Failed to remove listen from subscriptions list!");
return true;
}
Expand All @@ -157,7 +158,7 @@ export default {
stopListeningToAll: function(){
var remaining, subs = this.subscriptions || [];
while((remaining = subs.length)){
subs[0].stop();
subs[0].stop(subs);
_.throwIf(subs.length !== remaining - 1, "Failed to remove listen from subscriptions list!");
}
},
Expand Down