From 4818d99b13d2c6482e2ad60145aa9c3b86339a7f Mon Sep 17 00:00:00 2001 From: Peter Wagenet Date: Fri, 20 Jun 2025 16:40:39 -0700 Subject: [PATCH 1/2] Add Target Action Support deprecation guide --- .../v6/deprecate-target-action-support.md | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 content/ember/v6/deprecate-target-action-support.md diff --git a/content/ember/v6/deprecate-target-action-support.md b/content/ember/v6/deprecate-target-action-support.md new file mode 100644 index 00000000..8e550cc0 --- /dev/null +++ b/content/ember/v6/deprecate-target-action-support.md @@ -0,0 +1,61 @@ +--- +title: Deprecate Target Action Support +until: 7.0.0 +since: 6.8.0 +--- + +The `actions` hash on components, controllers, and routes, along with the `send` method, is deprecated. These APIs were primarily used with the now-deprecated `{{action}}` modifier and helper. + +The modern approach is to use standard class methods decorated with the `@action` decorator, and to pass functions directly. + +### `actions` hash and `send` + +**Old Pattern** + +Previously, you would define actions in an `actions` hash and use `this.send('actionName')` to call them. + +```javascript +// app/components/my-component.js +import Component from '@ember/component'; + +export default Component.extend({ + actions: { + save() { + // ... saving logic + }, + cancel() { + // ... cancel logic + } + }, + + someMethod() { + this.send('save'); + } +}); +``` + +**New Pattern** + +With modern classes, you can define methods directly on the class and decorate them with `@action`. You can then call them like any other method. + +```javascript +// app/components/my-component.js +import Component from '@glimmer/component'; +import { action } from '@ember/object'; + +export default class MyComponent extends Component { + @action + save() { + // ... saving logic + } + + @action + cancel() { + // ... cancel logic + } + + someMethod() { + this.save(); + } +} +``` From bedcdd6d061bc4ded71ae4160d64d8c735e27e8a Mon Sep 17 00:00:00 2001 From: Peter Wagenet Date: Mon, 23 Jun 2025 09:32:39 -0700 Subject: [PATCH 2/2] Update content/ember/v6/deprecate-target-action-support.md Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> --- content/ember/v6/deprecate-target-action-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/ember/v6/deprecate-target-action-support.md b/content/ember/v6/deprecate-target-action-support.md index 8e550cc0..32272d0c 100644 --- a/content/ember/v6/deprecate-target-action-support.md +++ b/content/ember/v6/deprecate-target-action-support.md @@ -4,7 +4,7 @@ until: 7.0.0 since: 6.8.0 --- -The `actions` hash on components, controllers, and routes, along with the `send` method, is deprecated. These APIs were primarily used with the now-deprecated `{{action}}` modifier and helper. +The `actions` hash on components, controllers, and routes, along with the `send` method, is deprecated. These APIs were primarily used with the previously-deprecated `{{action}}` modifier and helper. The modern approach is to use standard class methods decorated with the `@action` decorator, and to pass functions directly.