Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation guide for (action) / {{action}} #1377

Merged
merged 7 commits into from
May 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prism happy?
  • Loading branch information
NullVoxPopuli committed Mar 13, 2024
commit ed726687c236dce4d2ea600f9b87f2ceed5cfb3a
28 changes: 14 additions & 14 deletions content/ember/v5/deprecate-template-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ since: 5.10.0
### Scenario: `action` is passed a string

Before:
```hbs
```handlebars
<button type="button" {{action "plusOne"}}>
Click Me
</button>
```

After

```hbs
```handlebars
<button type="button" {{on 'click' this.plusOne}}>
Click Me
</button>
```
or, if `plusOne` is passed in as an argument
```hbs
```handlebars
<button type="button" {{on 'click' @plusOne}}>
Click Me
</button>
Expand All @@ -30,7 +30,7 @@ or, if `plusOne` is passed in as an argument
If the `plusOne` action is in an actions object, it needs to move out:
NullVoxPopuli marked this conversation as resolved.
Show resolved Hide resolved

Before:
```js
```javascript
import Component from '@glimmer/component';

export default class Demo extends Component {
Expand All @@ -42,7 +42,7 @@ export default class Demo extends Component {
}
```
or
```js
```javascript
import Component from '@ember/component';

export default class Demo extends Component {
Expand All @@ -54,7 +54,7 @@ export default class Demo extends Component {
}
```
or
```js
```javascript
import Component from '@ember/component';

export default Component.extend({
Expand All @@ -67,7 +67,7 @@ export default Component.extend({
```

After:
```js
```javascript
import Component from '@glimmer/component';
import { action } from '@ember/object';

Expand All @@ -86,36 +86,36 @@ Note that `@action` is completely different from `(action)` or `{{action}}` (and
### Scenario: `action` is passed a function reference

Before:
```hbs
```handlebars
<SomeComponent @update={{action this.plusOne}} />
```

After

```hbs
```handlebars
<SomeComponent @update={{this.plusOne}} />
```

### Scenario: `action` is passed parameters

Before:
```hbs
```handlebars
<SomeComponent @update={{action this.plus 1}} />
```

After:
```hbs
```handlebars
<SomeComponent @update={{fn this.plus 1}} />
```

### Scenario: `action` is used with `mut`

Before:
```hbs
```handlebars
<SomeComponent @update={{action (mut @value.property}} />
```
After:
```js
```javascript
// parent.js
import Component from '@glimmer/component';
import { action } from '@ember/object';
Expand All @@ -127,7 +127,7 @@ export default class SomeComponent extends Component {
}
}
```
```hbs
```handlebars
{{! parent.hbs }}
<SomeComponent @update={{this.handleUpdate}} />
```
Expand Down
Loading