Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 565 Bytes

no-observers.md

File metadata and controls

27 lines (22 loc) · 565 Bytes

Don't use observers

Rule name: no-observers

Usage of observers is very easy BUT it leads to hard to reason about consequences. Unless observers are necessary, it's better to avoid them.

{{input value=text key-up="change"}}
// GOOD
export default Controller.extend({
  actions: {
    change() {
      console.log(`change detected: ${this.get('text')}`);
    },
  },
});

// BAD
export default Model.extend({
  change: Ember.observer('text', function() {
    console.log(`change detected: ${this.get('text')}`);
  },
});