-
Notifications
You must be signed in to change notification settings - Fork 72
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
Move away from Evented for subscriptions #311
Comments
Is there more than just that RFC to go off of? Doesn’t look like they are definitely moving forward w/ it, that said, our use of Evented is very limited; while it’d be a breaking change, we could easily come up with a new pattern, or eliminate it all together and encourage people to setup their own observer if they want updates |
I recommend using the exported event utility functions over the mixin, for the following reasons:
API docs: Usage example in one of my recent addons: export default class CssModulesActiveRouteService extends Service {
@service router!: RouterService & {
routeWillChange(transition: Transition): void;
routeDidChange(transition: Transition): void;
};
init() {
super.init();
addListener(this.router, 'routeWillChange', this.handleRouteChange);
addListener(this.router, 'routeDidChange', this.handleRouteChange);
}
willDestroy() {
super.willDestroy();
removeListener(this.router, 'routeWillChange', this.handleRouteChange);
removeListener(this.router, 'routeDidChange', this.handleRouteChange);
}
@action
handleRouteChange(transition: Transition) {
// ...
}
} |
Super cool @buschtoens ; I hadn't seen that before. I'm a little confused though - from your reading are those on the chopping block as well? If not, and it's just the mixin that's going away, this is a great path forward, |
From the RFC Summary:
And further down in Alternatives:
So far the RFC is heavily debated and not accepted yet. The only thing we know for sure so far is that Mixins are gonna die in a fire 🔥 eventually. So refactoring away from the Since events are still central to Ember and Ember Data itself, I think there will be a "standard" replacement, should |
Thanks @buschtoens and @coladarci for the ideas. I have created a PR moving away from the mixin but still using ember events. Take a look at it #313 if you have time. |
Implemented in #313. |
ember-apollo-client
uses the Ember mixin Evented to allow users to subscribe to changes coming from a subscription.Ember is planning to deprecate Evented and Mixins, which are two things we are relying on for subscriptions. Thankfully we already have deprecated the mixin for query manager.
I would like to start thinking about alternatives from the Ember Evented and move away from that as soon as possible.
@coladarci since you are the original implementer of the subscription feature here, what do you think an alternative would look like?
The text was updated successfully, but these errors were encountered: