Skip to content

Commit

Permalink
Merge pull request #13 from engwan/master
Browse files Browse the repository at this point in the history
Clean up events when removing component
  • Loading branch information
mike-north committed Jul 12, 2015
2 parents e6a0d57 + 02bba45 commit 7d4f4f6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions addon/mixins/resize-aware.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ export default Ember.Mixin.create({
didInsertElement() {
this._super(...arguments);
if (this.get('resizeEventsEnabled')) {
this.get('resizeService').on('didResize', evt => {
this._handleResizeEvent(evt);
});
this.get('resizeService').on('didResize', this, this._handleResizeEvent);
}
if (this.get('resizeDebouncedEventsEnabled')) {
this.get('resizeService').on('debouncedDidResize', evt => {
this._handleDebouncedResizeEvent(evt);
});
this.get('resizeService').on('debouncedDidResize', this, this._handleDebouncedResizeEvent);
}
},

willDestroyElement() {
this._super(...arguments);
if (this.get('resizeEventsEnabled')) {
this.get('resizeService').off('didResize', this, this._handleResizeEvent);
}
if (this.get('resizeDebouncedEventsEnabled')) {
this.get('resizeService').off('debouncedDidResize', this, this._handleDebouncedResizeEvent);
}
},

Expand Down

0 comments on commit 7d4f4f6

Please sign in to comment.