-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLEANUP] Refactor DataAdapter to not use observers or array observers
The DataAdapter class is exposed specifically for the Ember Inspector to support Ember Data. Currently, the adapter relies on both array observers and standard observers. This PR refactors the adapter to use autotracking-based methods for tracking changes instead, with minimal API churn. The main change is to introduce a regular poll that checks for changes after each backburner runloop. There are two types of polling done: 1. `TypeWatcher`, which checks to see if a record array has changed at all (e.g. contents have changed) 2. `RecordsWatcher`, which watches the array as a whole _and_ the individual records within it. Whenever any changes occur, it reiterates the records array, and looks for new records, updated records, and removed records, and notifies of any changes. This removes the need for both array observers _and_ standard observers. Standard observers were previously used to detect changes on the model instances, but now we autotrack _serializing_ them, and that autotracking is used to detect if they've been updated. \## Breaking Changes - The `recordsRemoved` callback from `watchRecords` has changed. It now receives an array of removed records, _not_ an index and count. On the consuming side in Ember Inspector, we'll have to update the code to remove the items passed via id explicitly. - The `observeRecord` method has been removed. Because serializing the object _is_ observing it (via autotracking) there is no need to manually observe it. Users who are still implementing this method (e.g. Ember Data) can still keep it, and it shouldn't cause issues, it just will no longer be called.
- Loading branch information
Chris Garrett
committed
Feb 4, 2021
1 parent
2aa6395
commit d2909c4
Showing
3 changed files
with
234 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.