-
-
Notifications
You must be signed in to change notification settings - Fork 407
Deprecate Events System #1111
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 Events System #1111
Conversation
25d7f50 to
f9e6cf5
Compare
f9e6cf5 to
6e5d535
Compare
|
Needs deprecation guide |
|
The RFC currently recommends switching to the internal addListener/removeListener APIs. I'm thinking we should probably deprecate these too and just entirely discourage using Ember for handling listeners period. Do we have any suggestions for alternate libraries we should recommend? |
|
Probably:
|
|
According to ember-observer, some addons importing from |
|
emittery looks like the best alternative library for cases that can't use the built in CustomEvent. |
|
However, if we do deprecate support entirely, I think we may need to keep it around for the RouterService as an exception. |
|
I think we can kill have of the evented mixin tho / inline what we need in to the RouterService (we probably don't even need addListener / removeListener) |
|
The deprecation guide looks good, the text of the RFC needs updating to match (it mentions using |
text/1111-deprecate-evented-mixin.md
Outdated
|
|
||
| ## Summary | ||
|
|
||
| Deprecate the `Evented` Mixin in favor of just using the methods from `@ember/object/events`. |
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 RFC can be ready for FCP pending updates to the recommendation of what to use instead of the Evented mixin -- more closely matching what is in the PR'd deprecation guide ember-learn/deprecation-app#1404
|
I don't think this RFC is really complete without a description of how the RouterService events will work since today people might be (are, I know, because I am 😆) using |
|
@bendemboski the RFC says:
What further clarification do you need? Maybe if you can provide some example code that would be helpful. |
If I have code that looks like this: import { service } from '@ember/service';
import type RouterService from '@ember/routing/router-service';
import type Transition from '@ember/routing/transition';
import { addListener, removeListener } from '@ember/object/events';
import { registerDestructor } from '@ember/destroyable';
export default class SomeComponentOrWhatever {
@service('router') declare private router: RouterService;
constructor(/*...*/) {
super(/*...*/);
addListener(this.router, 'routeWillChange', this.onRouteWillChange);
registerDestructor(
this,
() => removeListener(this.router, 'routeWillChange', this.onRouteWillChange)
);
}
private readonly onRouteWillChange = (transition: Transition) => {
if (this.isUnsaved()) {
alert("Please save or cancel your changes.");
transition.abort();
}
};
}how do I rewrite it to not use |
|
I also really think we should be recommending a synchronous alternative to Therefore if we think it's within the scope of this RFC to recommend a specific alternative (which it doesn't have to be -- we could just say go pick your own library from among all the various options in the ecosystem), I think we should make both an asynchronous and synchronous recommendation. Or neither. It's possible that my perspective here is skewed because my 10+ year old application makes fairly heavy use of events that must be synchronous because of the application architecture, but I suspect I'm not alone. |
|
Oh, you already added synchronous recommendations to the deprecation guide -- great, thanks! Disregard my last comment 😄 |
|
@bendemboski for the router, you could use the methods that will continue to live on it: |
|
I somehow stumbled upon this and would like to share my 2 cents and experience when migrating an addon that makes use of events internally and also exposes them to the users. The RFC doesn't mention NodeJS as a target which is essentially Fastboot. |
|
We will try to address SSR in the deprecation guide when this progresses. |
7b550bf to
84e7ab3
Compare
Propose Deprecating Evented Mixin
Rendered
Summary
This pull request is proposing a new RFC for Deprecating the Evented Mixin.
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
Exploringlabel 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-Proposedis removed from the PR and the labelS-Exploringis added.Checklist to move to Accepted
Final Comment Periodlabel has been added to start the FCP