Skip to content

Commit

Permalink
use explicit observers
Browse files Browse the repository at this point in the history
  • Loading branch information
aomran committed Jun 6, 2015
1 parent 8198964 commit f3fb1c9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions addon/components/ember-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -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({
Expand All @@ -44,5 +48,5 @@ export default Ember.Component.extend({
} else {
chart.update();
}
})
}
});

0 comments on commit f3fb1c9

Please sign in to comment.