Skip to content

Add deprecation guides for ArrayProxy, ObjectProxy, and PromiseProxyMixin #1405

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 3 commits into
base: main
Choose a base branch
from

Conversation

wagenet
Copy link
Contributor

@wagenet wagenet commented Jun 20, 2025

Copy link

netlify bot commented Jun 20, 2025

Deploy Preview for ember-deprecations ready!

Name Link
🔨 Latest commit 10a111f
🔍 Latest deploy log https://app.netlify.com/projects/ember-deprecations/deploys/6876d49e15cba6000887d243
😎 Deploy Preview https://deploy-preview-1405--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.


`ArrayProxy` is deprecated. In modern Ember, you can replace `ArrayProxy` with native JavaScript classes and proxies. The best replacement depends on how you were using `ArrayProxy`. Some example use cases are shown below.

### Swapping Content
Copy link
Contributor

Choose a reason for hiding this comment

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

These guides show a way to achieve something technically the same as what people had before -- which is great -- but I also think we should guide users into what the modern Ember pattern would do instead. In this case, I believe that would mostly be tracked-built-ins.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracked built-ins doesn't have the swappable container behavior though. It seems like at least some of the uses were definitely looking for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

My general point is that we should point people to "the Ember way" going forwards, not just a strict technical replacement -- why did they want a swappable container? Do you still need that with @Tracked? (and applying to the other guides not just this first one that I commented on).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair. I'll think about how we can improve this to steer people in the right direction.

After:

```javascript
const person = { firstName: 'Tom', lastName: 'Dale' };
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const person = { firstName: 'Tom', lastName: 'Dale' };
const person = {
firstName: 'Tom',
lastName: 'Dale',
get fullName() {
// or person.firstName person.lastName
return `${this.firstName} ${this.lastName}`
}
};

why proxy at all?

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, good point. I guess we don't really need to proxy for this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, on further consideration, this would be for the case where you didn't want to modify the underlying content, hence a proxy.

const promise = new Promise(resolve => resolve({ value: 42 }));
const proxy = PromiseObject.create({ promise });

// In a template, you might have:
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use gjs / hbs here for highlighting this example

{{/let}}
```

For simpler cases where you don't need the full power of a library like `ember-concurrency`, you can manage the state manually with `@tracked` properties:
Copy link
Contributor

Choose a reason for hiding this comment

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

there is also getRequestState from warp-drive, which is probably worth mentioning

{{/if}}
```

Using a library like [ember-concurrency](https://ember-concurrency.com/docs/introduction) is highly recommended for managing asynchronous tasks in Ember applications, as it provides robust solutions for handling loading/error states, cancellation, and more.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Using a library like [ember-concurrency](https://ember-concurrency.com/docs/introduction) is highly recommended for managing asynchronous tasks in Ember applications, as it provides robust solutions for handling loading/error states, cancellation, and more.
Using a library like [ember-concurrency](https://ember-concurrency.com/docs/introduction) is highly recommended for managing concurrent asynchronous user-initiated tasks in Ember applications, as it provides robust solutions for handling loading/error states, cancellation, and more.

@ef4
Copy link
Contributor

ef4 commented Jun 27, 2025

I suspect the biggest hazard when trying to clear this deprecation is that computeds elsewhere in your app that depend on an ArrayProxy aren't going to react the same when you switch to TrackedArray. Maybe we should make a recommendation about removing computeds first before tackling this one?

@wagenet
Copy link
Contributor Author

wagenet commented Jun 27, 2025

I also want to deprecate computeds 😆

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