Skip to content

Commit

Permalink
proposed unsubscribe fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Eiten committed Jan 12, 2016
1 parent 17cd869 commit 62b7d0d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions polymer/js/fin-hypergrid-excel.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,17 @@
*
*/
subscribeToBus: function() {
fin.desktop.InterApplicationBus.subscribe('*', this.subscribe, this.subscriptionCallback.bind(this));
fin.desktop.InterApplicationBus.subscribe('*', 'ExcelError', this.errorCallback.bind(this));
this.unSubscribeToBus(); // automatically cancel existing subscription, if any

if (this.subscribe.toLowerCase() !== 'null') {
this.busHandlers ={
subscription: this.subscriptionCallback.bind(this),
error: this.errorCallback.bind(this)
};

fin.desktop.InterApplicationBus.subscribe('*', this.subscribe, this.busHandlers.subscription);
fin.desktop.InterApplicationBus.subscribe('*', 'ExcelError', this.busHandlers.error);
}
},

/**
Expand All @@ -189,8 +198,11 @@
*
*/
unSubscribeToBus: function() {
fin.desktop.InterApplicationBus.unsubscribe('*', this.subscribe, this.subscriptionCallback.bind(this));
fin.desktop.InterApplicationBus.unsubscribe('*', 'ExcelError', this.errorCallback.bind(this));
if (this.busHandlers) {
fin.desktop.InterApplicationBus.unsubscribe('*', this.subscribe, this.busHandlers.subscription);
fin.desktop.InterApplicationBus.unsubscribe('*', 'ExcelError', this.busHandlers.error);
delete this.busHandlers;
}
},

/**
Expand Down

0 comments on commit 62b7d0d

Please sign in to comment.