Skip to content

Commit

Permalink
feat(cleanup) destroy vue listeners pt. 2
Browse files Browse the repository at this point in the history
Closes #468.

This commit cleans up custom event listeners by destroying them when the
component no longer exists.
  • Loading branch information
nothingismagick committed May 7, 2019
1 parent b594fd0 commit 74f8da7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/zapHomeFiles/hud/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ Vue.component('hud-button', {
}
}
})
},
beforeDestroy () {
eventBus.$off('updateButton')
}
});

Expand Down Expand Up @@ -190,8 +193,11 @@ Vue.component('hud-buttons', {
eventBus.$on('removeButton', data => {
self.tools = self.tools.filter(tool => tool.name !== data.name);
})
},
beforeDestroy () {
eventBus.$off('addButton')
eventBus.$off('removeButton')
}

});

document.addEventListener("DOMContentLoaded", () => {
Expand All @@ -210,7 +216,7 @@ document.addEventListener("DOMContentLoaded", () => {
data: {

}
});
});
});

function doesContextApply(toolContext) {
Expand All @@ -225,7 +231,7 @@ function doesContextApply(toolContext) {
navigator.serviceWorker.addEventListener("message", event => {
var message = event.data;
let tool;

switch(message.action) {
case "broadcastUpdate":
tool = message.tool;
Expand Down

0 comments on commit 74f8da7

Please sign in to comment.