Skip to content

Add deprecation guide for Ember.Evented and @ember/object/events #1404

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wagenet
Copy link
Contributor

@wagenet wagenet commented Jun 20, 2025

@wagenet wagenet marked this pull request as draft June 20, 2025 21:43
Copy link

netlify bot commented Jun 20, 2025

Deploy Preview for ember-deprecations ready!

Name Link
🔨 Latest commit 8f81622
🔍 Latest deploy log https://app.netlify.com/projects/ember-deprecations/deploys/689b89cd22ba160008481f14
😎 Deploy Preview https://deploy-preview-1404--ember-deprecations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

this.#emitter.emit('loggedOut', oldUser);
}

// Public subscription methods
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, maybe

on(event, callbark) {
  return this.#emitter.on(event, callbark);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but what you have is easier to be type-safe


Please note: The methods from `Evented` (`on`, `one`, `off`, `trigger`, `has`) were also available on `Ember.Component`, `Ember.Route`, and `Ember.Router`. While usage on these objects is deprecated, the methods will continue to be supported and not deprecated on the `RouterService`, since key parts of its functionality are difficult to reproduce without them.

### Replacing `Evented` with `emittery`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, for any application at scale this is going to be a pretty huge change. Switching from synchronous events to asynchronous events is almost certain to not just be a drop-in replacement like this, and this deprecation guide doesn't mention that at all.

It looks like this deprecation guide is simultaneously doing two things:

  1. Describing the deprecation of Evented, and providing a possible path away from it
  2. Recommending that users make the architectural change of switching from synchronous event emitting to asynchronous event emitting.

I think these really need to be called out separately. Users should be aware that if they just follow this deprecation guide mechanically they'll be changing timing characteristics of their application in ways that can (and in many cases almost certainly will) break things. So I think we need to be more explicit that we're both recommending a new library to use and the change from synchronous to asynchronous events, and ideally offer up a recommendation of a synchronous eventing library for users that aren't ready to make that change but still need to deal with this deprecation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this callout. I would have thought existing events are async via the runloop. However, if we're sure this isn't the case, then we can definitely call it out in this guide.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observers are async by default, @ember/object/events and Evented are synchronous

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the guides to make this clear.

@bendemboski
Copy link

Is there a deprecation plan for @ember/object/events? The RFC referenced here (and the only open one I can find) is for Evented, and if all we are doing is deprecating Evented then why would the recommended path not be to move to @ember/object/events? Perhaps this is trying to be forward-looking to a time when we also deprecate @ember/object/events?

But deprecating @ember/object/events will also include changes to the framework since it is used for events such as the Router sending routeWillChange events...is the plan to remove those events entirely and replace them with something else? To make them asynchronous?

This guide seems to be addressing cases where Evented and @ember/object/events are used to send events from application code to application code, but I'm having trouble even thinking about that without not knowing the story for sending events from the framework to application code, so I'd think the deprecation guide would need to address that as well...

@wagenet
Copy link
Contributor Author

wagenet commented Aug 12, 2025

@bendemboski I've updated the RFC to match this deprecation guide.

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.

4 participants