Skip to content

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

Open
wagenet wants to merge 13 commits into
ember-learn:mainfrom
wagenet:events
Open

wagenet wants to merge 13 commits into
ember-learn:mainfrom
wagenet:events

Conversation

@wagenet

@wagenet wagenet commented Jun 20, 2025

Copy link
Copy Markdown
Contributor

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

netlify Bot commented Jun 20, 2025 •

Copy link
Copy Markdown

✅ 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.

Comment thread content/ember/v6/evented.md Outdated
Comment thread content/ember/v6/evented.md Outdated
Comment thread content/ember/v6/evented.md Outdated
Comment thread content/ember/v6/evented.md Outdated
this.#emitter.emit('loggedOut', oldUser);
}

// Public subscription methods

@NullVoxPopuli NullVoxPopuli Jun 23, 2025 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

Comment thread content/ember/v7/evented.md Outdated

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`

Copy link
Copy Markdown

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
Copy Markdown
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.

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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

wagenet commented Aug 12, 2025

Copy link
Copy Markdown
Contributor Author

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

Comment thread content/ember/v6/evented.md Outdated
Comment thread content/ember/v6/evented.md Outdated
> ⚠️ Important: `Ember.Evented` emits events *synchronously*. Changing to a library with asynchronous behavior, while recommended, may lead to subtle changes in your application's behavior.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't our first suggestion be to call methods directly where possible? If someone was using Evented with the example below I do not think my first suggestion would be to use Emittery but to refactor away from the pattern entirely.

I also think this needs examples for where it was used within Ember.Component, and Ember.Route and Router for the modern equivalents.

For example, for Ember Component, we should suggest moving to Glimmer components but also mention that instead of on('didInsertElement') that the hooks can be used directly.

They were also common with ember-simple-auth so we should suggest upgrading that addon or moving to the newer patterns there.

@netlify

netlify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for ember-deprecations ready!

Name Link
🔨 Latest commit 0ca2de0
🔍 Latest deploy log https://app.netlify.com/projects/ember-deprecations/deploys/6a7f6fe2dc62d00008a63756
😎 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.
🤖 Make changes Run an agent on this branch

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

Comment thread content/ember/v7/evented.md

@kategengler kategengler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I still think explicitly calling out replacing @ember/component with @glimmer/component but then discussing didInsertElement, willDestroy etc that were typically used with on would be good.

Comment thread content/ember/v7/evented.md Outdated
Comment thread content/ember/v7/evented.md Outdated
Comment thread content/ember/v7/evented.md Outdated
Comment thread content/ember/v7/evented.md Outdated
NullVoxPopuli and others added 2 commits August 14, 2026 15:22
Co-authored-by: Katie Gengler <katie@kmg.io>
Co-authored-by: Katie Gengler <katie@kmg.io>
NullVoxPopuli and others added 3 commits August 14, 2026 15:22
Co-authored-by: Katie Gengler <katie@kmg.io>
Co-authored-by: Katie Gengler <katie@kmg.io>
@NullVoxPopuli
NullVoxPopuli marked this pull request as ready for review August 14, 2026 21:40

The call is type-safe, and `logout` now states what it does instead of hiding the wiring in a subscription registered somewhere else.

### Classic component lifecycle hooks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Evented and @ember/component are about to be deprecated, so this prose should be take that in to consideration.

The before examples should at least look like code that someone might accidentally write today, rather than inherited from 10 years ago

(a migration this old could be useful as a last example, I suppose)

This branch has not been deployed

No deployments
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.

5 participants