Skip to content

Latest commit

 

History

History
57 lines (44 loc) · 1.01 KB

closure-actions.md

File metadata and controls

57 lines (44 loc) · 1.01 KB

ember/closure-actions

💼 This rule is enabled in the ✅ recommended config.

Always use closure actions (according to DDAU convention). Exception: only when you need bubbling.

Examples

export default Controller.extend({
  actions: {
    detonate() {
      alert('Kabooom');
    }
  }
});

Examples of incorrect code for this rule:

{{awful-component detonate='detonate'}}
// awful-component.js
export default Component.extend({
  actions: {
    pushLever() {
      this.sendAction('detonate');
    }
  }
});

Examples of correct code for this rule:

{{pretty-component boom=(action 'detonate')}}
// pretty-component.js
export default Component.extend({
  actions: {
    pushLever() {
      this.boom();
    }
  }
});

References

  • RFC to deprecate sendAction