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

[FEAT] Makes the @action decorator work in classic classes #17827

Merged
merged 1 commit into from
Apr 1, 2019

Conversation

pzuraq
Copy link
Contributor

@pzuraq pzuraq commented Mar 31, 2019

Currently, the new @action decorator is the only decorator in Ember
proper that doesn't work in classic classes currently. Since users could
define actions on the actions hash in classic classes, we didn't
originally see a reason for it to work in classic classes. However, with
the fact that the decorator now binds context, it may actually become
useful for users, especially if they decide to convert away from the
{{action}} modifier/helper.

const FooComponent = Component.extend({
  myAction: action(function() {
    // do a thing
  }),
});

Additionally, this makes them match up with our learning story for the
rest of decorators - they're always decorators, they just use
different syntax in native classes and classic classes.

Also updates setComputedDecorator and isComputedDecorator to setClassicDecorator and isClassicDecorator, since that is a bit more accurate for what they are being used for.

Currently, the new `@action` decorator is the only decorator in Ember
proper that doesn't work in classic classes currently. Since users could
define actions on the actions hash in classic classes, we didn't
originally see a reason for it to work in classic classes. However, with
the fact that the decorator now _binds context_, it may actually become
useful for users, especially if they decide to convert away from the
`{{action}}` modifier/helper.

```js
const FooComponent = Component.extend({
  myAction: action(function() {
    // do a thing
  }),
});
```

Additionally, this makes them match up with our learning story for the
rest of decorators - they're _always_ decorators, they just use
different syntax in native classes and classic classes.
@pzuraq pzuraq requested a review from rwjblue March 31, 2019 04:03
@rwjblue rwjblue merged commit dca9619 into master Apr 1, 2019
@rwjblue rwjblue deleted the make-action-decorator-classic branch April 1, 2019 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants