-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[FEAT] Updates @tracked to match the Tracked Properties RFC #17572
Conversation
93b8039
to
c2afda0
Compare
c3e98c2
to
99cb377
Compare
@pzuraq - Can you fix the package.json conflict here? |
Updates @Tracked to be a classic decorator as well as a standard native decorator, removes the ability to decorator native getters, and adds more tests for various situations and updates the existing tests. This PR also exposes the native `descriptor` decorator for use defining getters and setters: ```js import EmberObject, { descriptor } from '@ember/object'; import { tracked } from '@glimmer/tracking'; const Person = EmberObject.extend({ firstName: tracked({ value: 'Tom' }), lastName: tracked({ value: 'Dale' }), fullName: descriptor({ get() { return `${this.firstName} ${this.lastName}`; }, }), }); ```
99cb377
to
0070773
Compare
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 we may be missing some tests around recomputing during rendering.
@pzuraq - Would you mind adding some tests that use getters that then consume tracked properties in a template?
import { setComputedDecorator } from './lib/decorator'; | ||
import { tracked } from './lib/tracked'; | ||
|
||
// We have to set this here because there is a cycle of dependencies in tracked |
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.
We should work to remove this cycle before landing
Updates
@tracked
to be a classic decorator as well as a standardnative decorator, removes the ability to decorator native getters, and
adds more tests for various situations and updates the existing tests.
One thing to note is that users can still provide getters/setters to
classic classes via tracked:
The reasoning behind this is there is no way to do this currently, and
it allows us to match behavior between native/classic exactly.
Alternatively we could expose the native descriptor decorator that is
internal only right now, but unfortunately
computed
will not be ableto fill this role since it requires use of
Ember.set
, where nativegetters/setters do not.
TODO: