Comments (6)
Big thanks for digging further @runspired .
Very much appreciated.
The insight will surely help us tailor a tweak for our situation.
from data.
Hi Pankaj!
Thanks for the report.
Unfortunately (for you) this is expected and has always been the case. There is no potential fix for this in the @ember-data/model
paradigm. The model replacement that is under development won't provide any transforms out of the box, but its pattern for them would allow you to avoid this instability were you to implement one.
We hope to ship the replacement in 5.4, but that is still quite some time away for us.
from data.
related: #1540
from data.
Thank you for your swift and enlightening response.
I appreciate the suggestion to implement a fix for our projects, which we do intend to undertake. However, I wanted to bring to your attention that the date transform began triggering changes since the update to ember-data v4.12.0. Please note that this behaviour was not observed in the versions preceding this one. (my initial communication may not have reflected this point clearly)
Once again, thank you for your time and the insight you've provided. I (my team) looks forward to the forthcoming improvements in Version 5.4.
from data.
Please note that this behaviour was not observed in the versions preceding this one. (my initial communication may not have reflected this point clearly)
This has quite literally always been the case. hence the link to the longstanding issue from 2013 🙈
You will note the problem in that issue is exactly the same, and was never resolved for @ember-data/model
.
This is for the simple reason of how transforms work with @ember-data/model, or (dare I say) don't work. The typical assumption is that transforms work by converting data into/out of another format on access by the model. However, the model does not utilize transforms at all. Instead transforms are used by some (not all) serializers to transform data between the api's format and the cache's format.
What this means is that the date
transform, when used, has always been a leaky design. It results in the cache containing a Date
instance. Date instances are both mutable and two instances with an identical date are not strictly equal. This means any time data is received by the cache as a Date instance it will fail a simple ===
check and result in a notification being sent to the model indicating the field has changed.
Why this did not occur for you in 4.11 is anyone's guess, my suspicion would be that somewhere in your app is some code that in older versions would have worked around this limitation for you, perhaps with private api usage that no longer works.
from data.
After digging some more, a year after this issue was reported here, Ember changed isEqual
to compare date instances using getTime
, then still another year later in 2015 a change got slid in to make the ===
comparison use isEqual
. It was never explicitly to support dates and definitely didn't fix the underlying issue that any two objects that don't have strict identity will trigger notifications. In 4.12 as we worked to remove more of the unnecessary entanglement with Ember, we stopped using isEqual
. Since date comparison was not one of the widely known features of isEqual
this again went unnoticed by any except those like yourself that became dependent on it.
Generally speaking, such a notification in these cases is both safer and more desirable. In a pull base reactivity world, its unsafe to assume a non-strict comparison should go silent.
from data.
Related Issues (20)
- Feat - Additional Functionality Support in RequestManager for handler for Dynamic Handling beyond 'request' HOT 3
- Broken link in JSON Api ReadMe HOT 1
- cache.rollbackRelationships does not rollback the 2nd time after adding a record and rollback again HOT 3
- Understanding polymorphism HOT 2
- Assertion after saving a new relational record and tried to forget it HOT 4
- [3.28->4.7] `isLoaded` does not recompute if checked before the record has loaded. HOT 6
- Error `Could not find module `@warp-drive/core-types/request` imported from `(require)`` after update to 5.3.1 HOT 15
- bug: not tracking changes to empty relationship in 5.3.1+
- Breaks yarn install on Windows HOT 10
- Build broken after update from `5.3.0` to `5.3.3` HOT 3
- Deprecations will fire spuriously under strict ES module builds HOT 4
- Attributes with defaultValue functions not persisting HOT 8
- 🛤️ tracking: The Road to Polaris ✨ HOT 3
- Request can't handle `null` as response HOT 3
- Overridden `Model` methods have incorrect `this` type HOT 1
- Custom model instances’ type is not assignable to `Model` HOT 1
- EmberData's native types don't compile with glint HOT 9
- @ember-data/debug/data-adapter.js: Cannot read properties of undefined (reading 'env') HOT 2
- The kind `collection` is missing in schema-record HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data.