Skip to content

Conversation

wagenet
Copy link
Contributor

@wagenet wagenet commented Jun 20, 2025

Copy link

netlify bot commented Jun 20, 2025

Deploy Preview for ember-deprecations failed.

Name Link
🔨 Latest commit 32326fb
🔍 Latest deploy log https://app.netlify.com/projects/ember-deprecations/deploys/689b9d748d534c00088618a2

@wagenet
Copy link
Contributor Author

wagenet commented Jun 23, 2025

Looks like .hbs code blocks aren't allowed. Is this intentional?


In contrast, if a computed property is defined with its own setter, you **can** use a native JavaScript assignment to update it. Ember will correctly intercept this and run your setter logic.

```javascript
Copy link
Contributor

Choose a reason for hiding this comment

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

should these examples also have the modern native class equiv? this would help AI scanning later as we want to get rid of EmberObject


Then, use this modifier in your Glimmer component's template:

```hbs
Copy link
Contributor

Choose a reason for hiding this comment

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

gjs?

To trigger reactivity (like re-computing a dependent computed property) when changing a plain property, you **must** use the `set` function. A native JavaScript assignment (`person.firstName = 'Jane'`) will change the value but will **not** trigger reactivity.

```javascript
import { computed, set } from '@ember/object';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think instead of telling people to use set we should tell people to handle this case by refactoring their @computed away.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's a good call

Copy link
Contributor

Choose a reason for hiding this comment

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

Depending on where folks are with their migration, it could be good to have both -- the migration we have here -- but also how we would do it today using @tracked.

We could even use <details> to allow people to choose their own adventure (and not overwhelm them with a skyscraper of code blocks)

set fullName(value) {
const [firstName, lastName] = value.split(' ');
// Note: `set` is still used inside the setter itself
set(this, 'firstName', firstName);
Copy link
Contributor

Choose a reason for hiding this comment

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

set is not imported 🙈

since: 6.5.0
---

The `addObserver` and `removeObserver` methods from `@ember/object/observers` are deprecated. Instead of using observers, you should use tracked properties and native getters/setters.
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli Aug 8, 2025

Choose a reason for hiding this comment

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

we need another use case for before/after:

  • ember-concurrency's waitFor uses observers

and whatever these do:

  • ember-animated
  • ember-data
  • ember-power-select

Copy link
Contributor

Choose a reason for hiding this comment

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

waitFor can be implemented via a rAF loop

@ef4
Copy link
Contributor

ef4 commented Aug 15, 2025

We discussed that this is another place where it's probably important to expose well-curated and suitably-low-level-looking API for doing integrations with the auto tracking system that are not just our own DOM renderer. That would enable cases like the ember-concurrency example to do efficient integration without polling, rAF etc.

@ef4 ef4 mentioned this pull request Aug 29, 2025
11 tasks
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.

3 participants