Skip to content

Commit

Permalink
Merge pull request #24 from aomra015/glimmersupport
Browse files Browse the repository at this point in the history
use explicit observers
  • Loading branch information
aomran committed Jun 6, 2015
2 parents 8198964 + 4edfd85 commit 02904a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions addon/components/ember-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export default Ember.Component.extend({
}

this.set('chart', chart);
this.addObserver('data', this, this.updateChart);
this.addObserver('data.[]', this, this.updateChart);
this.addObserver('options', this, this.updateChart);
},

willDestroyElement: function(){
Expand All @@ -28,9 +31,12 @@ export default Ember.Component.extend({
}

this.get('chart').destroy();
this.removeObserver('data', this, this.updateChart);
this.removeObserver('data.[]', this, this.updateChart);
this.removeObserver('options', this, 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({
Expand All @@ -44,5 +50,5 @@ export default Ember.Component.extend({
} else {
chart.update();
}
})
}
});

0 comments on commit 02904a1

Please sign in to comment.