Skip to content

Latest commit

 

History

History
69 lines (53 loc) · 1.14 KB

classic-decorator-hooks.md

File metadata and controls

69 lines (53 loc) · 1.14 KB

classic-decorator-hooks

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

Use the correct lifecycle hooks in classic and non-classic classes. Classic classes should use init, and non-classic classes should use constructor. Additionally, non-classic classes may not use destroy.

Examples

Examples of incorrect code for this rule:

export default class MyService extends Service {
  init() {
    // ...
  }

  destroy() {
    // ...
  }
}
@classic
export default class MyService extends Service {
  constructor() {
    super();
    // ...
  }
}

Examples of correct code for this rule:

@classic
export default class MyService extends Service {
  init() {
    // ...
  }

  destroy() {
    // ...
  }
}
export default class MyService extends Service {
  constructor() {
    super();
    // ...
  }

  willDestroy() {
    // ...
  }
}

References

Related Rules