Last active
May 30, 2019 21:39
-
-
Save hmcq6/40f8afd2a75d0aed7040533888f3fc25 to your computer and use it in GitHub Desktop.
Leaking Listener Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
time: null, | |
_handler: null, | |
didInsertElement() { | |
this._super(...arguments); | |
console.log(this.time); | |
this.set('_handler', function() { | |
console.log('wiggity'); | |
}); | |
this.element.addEventListener('click', this.get('_handler')); | |
}, | |
willDestroyElement() { | |
this.element.removeEventListener('click', this.get('_handler')); | |
this.set('_handler', null); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
time: 0, | |
timeIsChanging: true, | |
init() { | |
this._super(...arguments); | |
setInterval(() => this.increment(), 200); | |
}, | |
increment() { | |
Ember.set(this, 'timeIsSet', false); | |
Ember.set(this, 'time', Ember.get(this, 'time') + 1); | |
Ember.run.next(() => { | |
Ember.set(this, 'timeIsSet', true); | |
}); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment