-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Deprecate the (action) template helper and modifier #1006
Conversation
RFC Review (1) are happy for this to go to exploring. Over to RFC Review (2). /cc @kategengler (just to bubble this up) |
After | ||
|
||
```hbs | ||
<SomeComponent @update={{this.plusOne}} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may need to note that plusOne
on the class will need the @action
decorator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action decorator is only needed for {{action
compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've mentioned this once during the first scenario -- do you think it's enough?
## Unresolved questions | ||
|
||
- Could there be a codemod? | ||
_Potentially_ for action usage that references `this.properties`. For string actions, it's impossible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And at minima the codemod would be able to emit warnings in that case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea
Does this end up implicitly deprecating the classic class syntax? Is there a migration path for this kind of component which doesn't involve porting to ES6 class syntax first? import Component from '@ember/component';
export default Component.extend({
actions: {
doThing() {
this.thing;
}
}
}); <button {{action "doThing"}}>do</button> Actually, is there even a way to write EmberComponents with ES6 class syntax? Does this proposal end up deprecating EmberComponents? |
yes! (see below)
It does not -- you can remain in the classic world by migrating to this. import Component from '@ember/component';
import { action, set } from '@ember/object';
Component.extend({
count: 0,
increment: action(function () {
set(this, 'count', this.count + 1);
}),
});
There is! (and this is preferred!, and what was recommended during the era leading up to Octane, iirc) looks like this: import Component from '@ember/component';
import { tracked } from '@glimmer/tracking';
export default class Demo extends Component {
@tracked count = 0;
increment = () => this.count++;
} And even with ember components, you can use the latest format, GJS, which looks like this: import Component from '@ember/component';
import { tracked } from '@glimmer/tracking';
import { on } from '@ember/modifier';
export default class Demo extends Component {
@tracked count = 0;
increment = () => this.count++;
<template>
<p>Clicked: {{this.count}}</p>
<button {{on 'click' this.increment}}>click</button>
</template>
} Personally, I'd opt to go straight to gjs (and glimmer) at that point (IFF there are sufficient tests for the component that is -- I like safe migrations 😅 ) import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { on } from '@ember/modifier';
export default class HelloWorld extends Component {
@tracked count = 0;
increment = () => this.count += 1;
<template>
<p>Count: {{this.count}}</p>
<button {{on "click" this.increment}}>Click</button>
</template>
} (note that this is nearly identical (DX-wise) to the ember component version, except you'll inherently get a slight perf boost, due to glimmer components just being less complex) |
Phew! Porting all those classic components to the For porting them to ES6, the next smallest hop would probably be something like this |
ember-native-class-codemod will get your ember components to es6 syntax, for the most part. |
Before: | ||
```js | ||
import Component from '@glimmer/component'; | ||
|
||
export default class Demo extends Component { | ||
actions = { | ||
plusOne() { | ||
/* ... */ | ||
} | ||
} | ||
} | ||
``` | ||
or | ||
```js | ||
import Component from '@ember/component'; | ||
|
||
export default class Demo extends Component { | ||
actions = { | ||
plusOne() { | ||
/* ... */ | ||
} | ||
} | ||
} | ||
``` | ||
or | ||
```js | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
actions: { | ||
plusOne() { | ||
/* ... */ | ||
} | ||
} | ||
}) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should have independent "after" examples for each of these before cases. The way this is written right now suggests that you might need to upgrade to glimmer class-based components to get around this deprecation, which isn't technically true (even if encouraged 😂)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, but this sounds like a detail for the deprecation guide PR 🎉
https://github.com/emberjs/rfcs/blob/master/deprecation-template.md#transition-path
states that:
enough detail for someone who uses the deprecated functionality to understand, for someone to write the deprecation guide, and for someone familiar with the implementation to implement.
So since whether or not to choose @ember/component
or @glimmer/component
is a point-in-time and learning based decision, I think it makes sense to defer to the deprecation guide PR to work out how all that is formatted, the prose, etc.
Advance RFC #1006 `"Deprecate (action) template helper and {{action}} modifier."` to Stage Ready for Release
Advance RFC #1006 `"Deprecate (action) template helper and {{action}} modifier."` to Stage Released
Advance RFC #1006 `"Deprecate (action) template helper and {{action}} modifier."` to Stage Recommended
Propose deprecating the
(action)
template helper and modifierRendered
Summary
This pull request is proposing a new RFC.
To succeed, it will need to pass into the Exploring Stage), followed by the Accepted Stage.
A Proposed or Exploring RFC may also move to the Closed Stage if it is withdrawn by the author or if it is rejected by the Ember team. This requires an "FCP to Close" period.
An FCP is required before merging this PR to advance to Accepted.
Upon merging this PR, automation will open a draft PR for this RFC to move to the Ready for Released Stage.
Exploring Stage Description
This stage is entered when the Ember team believes the concept described in the RFC should be pursued, but the RFC may still need some more work, discussion, answers to open questions, and/or a champion before it can move to the next stage.
An RFC is moved into Exploring with consensus of the relevant teams. The relevant team expects to spend time helping to refine the proposal. The RFC remains a PR and will have an
Exploring
label applied.An Exploring RFC that is successfully completed can move to Accepted with an FCP is required as in the existing process. It may also be moved to Closed with an FCP.
Accepted Stage Description
To move into the "accepted stage" the RFC must have complete prose and have successfully passed through an "FCP to Accept" period in which the community has weighed in and consensus has been achieved on the direction. The relevant teams believe that the proposal is well-specified and ready for implementation. The RFC has a champion within one of the relevant teams.
If there are unanswered questions, we have outlined them and expect that they will be answered before Ready for Release.
When the RFC is accepted, the PR will be merged, and automation will open a new PR to move the RFC to the Ready for Release stage. That PR should be used to track implementation progress and gain consensus to move to the next stage.
Checklist to move to Exploring
S-Proposed
is removed from the PR and the labelS-Exploring
is added.Checklist to move to Accepted
Final Comment Period
label has been added to start the FCP