Skip to content

Commit

Permalink
Merge pull request #77 from nsftx/task/CU-8694xgzft/master_reset
Browse files Browse the repository at this point in the history
Add reset method to clear everything up
  • Loading branch information
Lanchi authored Jun 26, 2024
2 parents d4411da + b18d489 commit 244c06b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/master_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var masterGateway = {
msgSender: 'Master',

eventHandler: null,

init: function (config) {
var slaves = config.slaves || config.products;
this.initialized = true;
Expand Down Expand Up @@ -389,6 +389,16 @@ var masterGateway = {
}
},

reset: function () {
Object.keys(this.slaves).forEach(function (slaveId) {
this.removeSlave(slaveId);
});

this.clearSubscriptions();

window.removeEventListener('message', this.handleMessage.bind(this));
},

_createCallbackSubscription : function(event, def, idx) {
var subscribed;
var cbHash = event + '_' + idx;
Expand Down

0 comments on commit 244c06b

Please sign in to comment.