-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for ember-deprecations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
After: | ||
|
||
```javascript | ||
const person = { firstName: 'Tom', lastName: 'Dale' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
{{/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: |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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? |
I also want to deprecate computeds 😆 |
proxy.get('firstObject'); // 'amoeba' | ||
``` | ||
|
||
After: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to add two approaches for "After" in <details>
for:
- exact technical replacement (change no consuming code) (what is shown here already)
- recommended migration path for canonical array using
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description on this section reads:
If you were using
ArrayProxy
to easily swap out the underlying array while keeping a stable reference, you can achieve a similar, transparent effect using a nativeProxy
backed by a class with a@tracked
property. Again, prefer tracked arrays and properties if you can refactor your code to use them.
So I think it's clear that this is the "exact technical" replacement.
I've added a note about ComputedProperties. |
RFC: emberjs/rfcs#1112