Skip to content

Latest commit

 

History

History
55 lines (43 loc) · 957 Bytes

closure-actions.md

File metadata and controls

55 lines (43 loc) · 957 Bytes

closure-actions

✅ The "extends": "plugin:ember/recommended" property in a configuration file enables this rule.

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