From f3fb1c98ce377a1ad4c198ff95e7096807900829 Mon Sep 17 00:00:00 2001 From: Ahmed O Date: Sat, 6 Jun 2015 14:21:28 -0400 Subject: [PATCH 1/2] use explicit observers --- addon/components/ember-chart.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addon/components/ember-chart.js b/addon/components/ember-chart.js index 2d95d15..1ce3974 100644 --- a/addon/components/ember-chart.js +++ b/addon/components/ember-chart.js @@ -20,6 +20,8 @@ export default Ember.Component.extend({ } this.set('chart', chart); + this.addObserver('data.[]', this.updateChart); + this.addObserver('options', this.updateChart); }, willDestroyElement: function(){ @@ -28,9 +30,11 @@ export default Ember.Component.extend({ } this.get('chart').destroy(); + this.removeObserver('data.[]', this.updateChart); + this.removeObserver('options', this.updateChart); }, - updateChart: Ember.observer('data', 'data.[]', 'options', function(){ + updateChart: function(){ var chart = this.get('chart'); var data = this.get('data'); var redraw = ChartDataUpdater.create({ @@ -44,5 +48,5 @@ export default Ember.Component.extend({ } else { chart.update(); } - }) + } }); From 4edfd8544fc9d5d388a6330faac3d9b6dcc9d38e Mon Sep 17 00:00:00 2001 From: Ahmed O Date: Sat, 6 Jun 2015 16:20:08 -0400 Subject: [PATCH 2/2] fix observers --- addon/components/ember-chart.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addon/components/ember-chart.js b/addon/components/ember-chart.js index 1ce3974..0f4ab13 100644 --- a/addon/components/ember-chart.js +++ b/addon/components/ember-chart.js @@ -20,8 +20,9 @@ export default Ember.Component.extend({ } this.set('chart', chart); - this.addObserver('data.[]', this.updateChart); - this.addObserver('options', this.updateChart); + this.addObserver('data', this, this.updateChart); + this.addObserver('data.[]', this, this.updateChart); + this.addObserver('options', this, this.updateChart); }, willDestroyElement: function(){ @@ -30,8 +31,9 @@ export default Ember.Component.extend({ } this.get('chart').destroy(); - this.removeObserver('data.[]', this.updateChart); - this.removeObserver('options', this.updateChart); + this.removeObserver('data', this, this.updateChart); + this.removeObserver('data.[]', this, this.updateChart); + this.removeObserver('options', this, this.updateChart); }, updateChart: function(){