mirror of
https://github.com/documize/community.git
synced 2025-07-21 14:19:43 +02:00
Correctly unsubscribe from JS event listeners
This commit is contained in:
parent
9fd002b5da
commit
1e217274c6
3 changed files with 13 additions and 13 deletions
|
@ -58,7 +58,7 @@ export default Component.extend({
|
|||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
this.eventBus.unsubscribe('documentPageAdded');
|
||||
this.eventBus.unsubscribe('documentPageAdded', this, 'onDocumentPageAdded');
|
||||
},
|
||||
|
||||
onDocumentPageAdded(pageId) {
|
||||
|
|
|
@ -79,8 +79,8 @@ export default Component.extend(Modals, {
|
|||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.eventBus.unsubscribe('notifyUser');
|
||||
this.eventBus.unsubscribe('pinChange');
|
||||
this.eventBus.unsubscribe('notifyUser', this, 'processNotification');
|
||||
this.eventBus.unsubscribe('pinChange', this, 'setupPins');
|
||||
iziToast.destroy();
|
||||
},
|
||||
|
||||
|
|
|
@ -13,18 +13,18 @@ import Evented from '@ember/object/evented';
|
|||
import Service from '@ember/service';
|
||||
|
||||
export default Service.extend(Evented, {
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
let _this = this;
|
||||
// init() {
|
||||
// this._super(...arguments);
|
||||
// let _this = this;
|
||||
|
||||
window.addEventListener("scroll", _.throttle(function() {
|
||||
_this.publish('scrolled', null);
|
||||
}, 100));
|
||||
// window.addEventListener("scroll", _.throttle(function() {
|
||||
// _this.publish('scrolled', null);
|
||||
// }, 100));
|
||||
|
||||
window.addEventListener("resize", _.debounce(function() {
|
||||
_this.publish('resized', null);
|
||||
}, 100));
|
||||
},
|
||||
// window.addEventListener("resize", _.debounce(function() {
|
||||
// _this.publish('resized', null);
|
||||
// }, 100));
|
||||
// },
|
||||
|
||||
publish: function() {
|
||||
return this.trigger.apply(this, arguments);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue