widget: better event listener cleanup
This commit is contained in:
parent
317216bfdc
commit
03c46d421f
2 changed files with 5 additions and 1 deletions
|
|
@ -158,7 +158,6 @@ class WidgetManager extends EventEmitter {
|
|||
if (this.widgets[hash]) {
|
||||
if (this.widgets[hash].onRemove) {
|
||||
this.widgets[hash].onRemove()
|
||||
this.widgets[hash].off()
|
||||
}
|
||||
|
||||
delete this.widgets[hash]
|
||||
|
|
@ -168,6 +167,7 @@ class WidgetManager extends EventEmitter {
|
|||
})
|
||||
|
||||
widget.trigger('widget-removed', {widget: widget})
|
||||
widget.off('widget-removed')
|
||||
|
||||
}
|
||||
if (id && this.idRoute[id].indexOf(hash) != -1) this.idRoute[id].splice(this.idRoute[id].indexOf(hash), 1)
|
||||
|
|
|
|||
|
|
@ -1268,6 +1268,10 @@ class Widget extends EventEmitter {
|
|||
}
|
||||
|
||||
this.removed = true
|
||||
for (var name in this._listeners) {
|
||||
if (name !== 'widget-removed') this.off(name)
|
||||
}
|
||||
|
||||
widgetManager.off(undefined, undefined, this)
|
||||
sessionManager.off(undefined, undefined, this)
|
||||
this.removeOscReceivers()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue