From fa5aceb7b36ea72f27b3f7504b060ef32676d9e4 Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Mon, 21 Jun 2021 10:44:59 -0700 Subject: [PATCH] Bind method to 'this' so that its listeners are correctly unbound on destroy (#3948) * Bind method to 'this' so that its listener can work correctly * Bind this for toggling subscriptions as well --- src/plugins/condition/StyleRuleManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/condition/StyleRuleManager.js b/src/plugins/condition/StyleRuleManager.js index 62660b02cb..a1ab1b6d4c 100644 --- a/src/plugins/condition/StyleRuleManager.js +++ b/src/plugins/condition/StyleRuleManager.js @@ -27,15 +27,17 @@ export default class StyleRuleManager extends EventEmitter { super(); this.openmct = openmct; this.callback = callback; + this.refreshData = this.refreshData.bind(this); + this.toggleSubscription = this.toggleSubscription.bind(this); if (suppressSubscriptionOnEdit) { - this.openmct.editor.on('isEditing', this.toggleSubscription.bind(this)); + this.openmct.editor.on('isEditing', this.toggleSubscription); this.isEditing = this.openmct.editor.editing; } if (styleConfiguration) { this.initialize(styleConfiguration); if (styleConfiguration.conditionSetIdentifier) { - this.openmct.time.on("bounds", this.refreshData.bind(this)); + this.openmct.time.on("bounds", this.refreshData); this.subscribeToConditionSet(); } else { this.applyStaticStyle();