-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Model's property observer is triggered after save although value isn't changed by response #2937
Comments
Can you post an example model definition and payload? |
Note, this is similar to: @stefanpenner do we have an ETA for this? |
Most of the attrs/relationships don't use Ember Computed Properties for performance reasons, so I don't think this is similar to the other issue. |
import DS from 'ember-data';
export default DS.Model.extend({
accountNumbers: DS.attr('string',{defaultValue: ''}),
});
{
"lead": {
"accountNumbers": "911000319219,851002826770,851002826771"
}
}
{
"status": "SUCCESS",
"data": {
"lead": {
"id": "xxxxxx",
"accountNumbers": "911000319219,851002826770,851002826771"
}
},
"errors": {},
"meta": {}
} |
The observer on the accountNumbers get triggered after save. Although console.logging the value gives exactly the same. Also, removing the accountNumbers from the response payload stop the observer being called again. |
I can see why this is happening. When you set attributes on a record we store those changes internally in See #2649 (comment) I still have a vision™ of completing my branch fixing this... |
Does it mean that |
Yes, if the record is newly created. |
Can you provide a failing test? I think this shouldn't be too hard to solve. I think we probably just need to move https://github.com/emberjs/data/pull/2649/files#diff-4cc9f4885e8425eeaa555ef3648588aeR866 couple lines up |
I have an observer on a model's property.
When the model is saved, and only if the API returns the property (unchanged) as part of the payload, then the observer is being triggered.
Since the property hasn't changed - same type, same value - I'm left confused as to why my observer is being triggered after save.
The text was updated successfully, but these errors were encountered: