|
| 1 | +--- |
| 2 | +stage: accepted |
| 3 | +start-date: 2025-07-15T00:00:00.000Z |
| 4 | +release-date: # In format YYYY-MM-DDT00:00:00.000Z |
| 5 | +release-versions: |
| 6 | +teams: |
| 7 | + - framework |
| 8 | +prs: |
| 9 | + accepted: https://github.com/emberjs/rfcs/pull/1041 |
| 10 | +project-link: |
| 11 | +suite: |
| 12 | +--- |
| 13 | + |
| 14 | +# Deprecate TargetActionSupport |
| 15 | + |
| 16 | +## Summary |
| 17 | + |
| 18 | +Deprecate `send` and the corresponding TargetActionSupport. |
| 19 | + |
| 20 | +## Motivation |
| 21 | + |
| 22 | +These are legacy patterns that are no longer recommended in modern Ember code. The primary way to interact with this system was the now-deprecated `{{action}}` modifier/helper. The modern approach is to use standard class methods (optionally decorated with `@action`) and to pass functions directly, following the Data Down, Actions Up (DDAU) pattern. |
| 23 | + |
| 24 | +See also: [Target Action Support deprecation guide](https://deploy-preview-1410--ember-deprecations.netlify.app/deprecations/v6.x/#target-action-support) |
| 25 | + |
| 26 | +## Detailed design |
| 27 | + |
| 28 | +This RFC proposes to deprecate and remove the following: |
| 29 | + |
| 30 | +- `TargetActionSupport` mixin, specifically the `triggerAction` method |
| 31 | +- `ActionHandler` mixin, specifically the `send` method |
| 32 | +- `ActionSupport` mixin, specifically the `send` method |
| 33 | + |
| 34 | +These mixins and methods are legacy patterns that predate modern Ember features like native classes, tracked properties, and Glimmer components. Their primary use case was to support the `{{action}}` helper/modifier, which has already been deprecated. |
| 35 | + |
| 36 | +### Deprecation Process |
| 37 | + |
| 38 | +1. Mark the affected mixins and methods as deprecated in the next minor release, with clear deprecation warnings and migration guides. |
| 39 | +2. Update documentation to reflect the deprecation and recommend alternatives (such as closure actions, service injection, or direct method calls). |
| 40 | +3. Remove the deprecated APIs in a future major release. |
| 41 | + |
| 42 | +### Migration Path |
| 43 | + |
| 44 | +- For `send` and `triggerAction`, recommend direct method invocation or using closure actions. |
| 45 | +- Provide codemods or lint rules to help users identify and migrate away from these patterns. |
| 46 | + |
| 47 | + |
| 48 | +### Example Migration |
| 49 | + |
| 50 | +**Before:** |
| 51 | + |
| 52 | +```js |
| 53 | +// Using send |
| 54 | +this.send('doSomething'); |
| 55 | +``` |
| 56 | + |
| 57 | +**After:** |
| 58 | + |
| 59 | +```js |
| 60 | +// Direct method call |
| 61 | +this.doSomething(); |
| 62 | +``` |
| 63 | + |
| 64 | +**Before:** |
| 65 | + |
| 66 | +```js |
| 67 | +// Using triggerAction |
| 68 | +this.triggerAction({ action: 'save' }); |
| 69 | +``` |
| 70 | + |
| 71 | +**After:** |
| 72 | + |
| 73 | +```js |
| 74 | +// Direct method call or closure action |
| 75 | +this.save(); |
| 76 | +// or pass a closure action |
| 77 | +@action |
| 78 | +save() { /* ... */ } |
| 79 | +``` |
| 80 | + |
| 81 | + |
| 82 | +### Deprecation Message |
| 83 | + |
| 84 | +When these APIs are used, emit a deprecation warning: |
| 85 | + |
| 86 | +``` |
| 87 | +The use of `send`/`triggerAction`/target action support is deprecated. See https://deploy-preview-1410--ember-deprecations.netlify.app/deprecations/v6.x/#target-action-support for migration details. |
| 88 | +``` |
| 89 | + |
| 90 | +### Ecosystem Implications |
| 91 | + |
| 92 | +- **Lint rules:** Add rules to `ember-template-lint` and `eslint-plugin-ember` to flag usage of these APIs. |
| 93 | +- **Features replaced/obsolete:** The `{{action}}` helper/modifier and related mixins are already deprecated or replaced by modern patterns. |
| 94 | +- **Ember Inspector:** Remove or update any features that rely on these APIs. |
| 95 | +- **Server-side Rendering, Ember Engines, Addon Ecosystem, IDE Support:** No direct impact, but documentation and blueprints should be updated to avoid these patterns. |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | + |
| 100 | +## How we teach this |
| 101 | + |
| 102 | +This deprecation is a continuation of Ember's modernization, moving away from legacy patterns toward direct method calls and closure actions. The recommended terminology is "direct method invocation" and "closure actions". |
| 103 | + |
| 104 | +**Guides and Documentation:** |
| 105 | +- Remove references to `send`, `triggerAction`, and the affected mixins from the Ember Guides and API docs. |
| 106 | +- Add a deprecation guide (see above) and migration examples. |
| 107 | +- Update blog posts and tutorials to avoid these patterns. |
| 108 | + |
| 109 | +**For Existing Users:** |
| 110 | +- Announce the deprecation in release notes and community channels. |
| 111 | +- Provide codemods, lint rules, and clear migration paths. |
| 112 | + |
| 113 | +**For New Users:** |
| 114 | +- Ensure new learning materials do not mention or rely on these legacy APIs. |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | + |
| 119 | +## Drawbacks |
| 120 | + |
| 121 | +- Some legacy apps and addons may still rely on these patterns, so deprecation and removal could require migration effort. |
| 122 | +- Removing these APIs may break code that uses dynamic action dispatching via `send` or `triggerAction`. |
| 123 | +- There is a risk of fragmenting documentation and learning resources during the transition period. |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | + |
| 128 | +## Alternatives |
| 129 | + |
| 130 | +- Do nothing: Continue to support these legacy APIs, but this increases maintenance burden and hinders Ember's modernization. |
| 131 | +- Deprecate but do not remove: This avoids breaking changes but leaves deprecated code in the framework indefinitely. |
| 132 | +- Replace with a new abstraction: No clear need, as modern JavaScript and Ember patterns already provide better alternatives. |
| 133 | + |
| 134 | +**Prior Art:** |
| 135 | +Other frameworks (React, Vue, Angular) encourage direct method calls or use of closures for event handling, rather than a dynamic action dispatch system. |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | + |
| 140 | +## Unresolved questions |
| 141 | + |
| 142 | +- Are there any edge cases or internal uses of these mixins that need special handling? |
| 143 | +- Should we provide an official codemod for migration, or rely on lint rules and manual refactoring? |
| 144 | +- Are there any third-party addons that would be significantly impacted and need outreach or support? |
0 commit comments