Skip to content
Snippets Groups Projects
Commit 35f2aa32 authored by Mathis Neumann's avatar Mathis Neumann
Browse files

avoid listener leaks when the user leaves the view

parent 3e24e08f
No related branches found
No related tags found
No related merge requests found
...@@ -17,14 +17,22 @@ export default Ember.Component.extend({ ...@@ -17,14 +17,22 @@ export default Ember.Component.extend({
'concentric', 'concentric',
'breadthfirst' 'breadthfirst'
], ],
resizing: false,
init() { init() {
this._super(); this._super();
this.debug('init!', this.get('graph'), this.get('layoutAlgorithm')); this.debug('init!', this.get('graph'), this.get('layoutAlgorithm'));
// add class while the sidebar grows // add class while the sidebar grows
const visualisationEvents = this.get('visualisationEvents'); const visualisationEvents = this.get('visualisationEvents');
visualisationEvents.on('resize:start', () => this.set('resizing', true)); const startListener = () => this.set('resizing', true);
visualisationEvents.on('resize:end', () => this.set('resizing', false)); const endListener = () => this.set('resizing', false);
visualisationEvents.on('resize:start', startListener);
visualisationEvents.on('resize:end', endListener);
this.on('willDestroyElement', () => {
visualisationEvents.off('resize:start', startListener);
visualisationEvents.off('resize:end', endListener);
});
}, },
actions: { actions: {
selectLayoutAlgorithm(value) { selectLayoutAlgorithm(value) {
......
...@@ -19,7 +19,12 @@ export default Ember.Component.extend({ ...@@ -19,7 +19,12 @@ export default Ember.Component.extend({
this.debug('loaded', this.get('graph')); this.debug('loaded', this.get('graph'));
// we only need to listen to :end since opacity changes are done via css, since architecture-viewer adds a resizing class // we only need to listen to :end since opacity changes are done via css, since architecture-viewer adds a resizing class
this.get('visualisationEvents').on('resize:end', this.resize.bind(this)); const visualisationEvents = this.get('visualisationEvents');
const resizeListener = this.resize.bind(this);
visualisationEvents.on('resize:end', resizeListener);
this.on('willDestroyElement', () => {
visualisationEvents.off('resize:start', resizeListener);
});
}, },
willDestroyElement() { willDestroyElement() {
clearInterval(this.interval); clearInterval(this.interval);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment