Skip to content

Commit

Permalink
[PERF] Batch RecordArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Mar 10, 2017
1 parent e30a97d commit f48e473
Show file tree
Hide file tree
Showing 14 changed files with 330 additions and 219 deletions.
18 changes: 15 additions & 3 deletions addon/-private/system/model/internal-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class InternalModel {
this._record = null;
this._isDestroyed = false;
this.isError = false;
this._isUpdatingRecordArrays = false;
this._isUpdatingRecordArrays = false; // used by the recordArrayManager

// During dematerialization we don't want to rematerialize the record. The
// reason this might happen is that dematerialization removes records from
Expand Down Expand Up @@ -267,6 +267,20 @@ export default class InternalModel {
return this.__implicitRelationships;
}

isHiddenFromRecordArrays() {
// During dematerialization we don't want to rematerialize the record.
// recordWasDeleted can cause other records to rematerialize because it
// removes the internal model from the array and Ember arrays will always
// `objectAt(0)` and `objectAt(len -1)` to check whether `firstObject` or
// `lastObject` have changed. When this happens we don't want those
// models to rematerialize their records.

return this._isDematerializing ||
this.isDestroyed ||
this.currentState.stateName === 'root.deleted.saved' ||
this.isEmpty();
}

isEmpty() {
return this.currentState.isEmpty;
}
Expand Down Expand Up @@ -942,8 +956,6 @@ export default class InternalModel {
@private
*/
updateRecordArrays() {
if (this._isUpdatingRecordArrays) { return; }
this._isUpdatingRecordArrays = true;
this.store.recordArrayManager.recordDidChange(this);
}

Expand Down
Loading

0 comments on commit f48e473

Please sign in to comment.