Add deprecation guides for ArrayProxy, ObjectProxy, and PromiseProxyMixin#1405
Add deprecation guides for ArrayProxy, ObjectProxy, and PromiseProxyMixin#1405wagenet wants to merge 4 commits intoember-learn:mainfrom
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.
| 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.
Yeah, good point. I guess we don't really need to proxy for this case.
There was a problem hiding this comment.
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.
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.
| 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.
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.
The description on this section reads:
If you were using
ArrayProxyto easily swap out the underlying array while keeping a stable reference, you can achieve a similar, transparent effect using a nativeProxybacked by a class with a@trackedproperty. 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