Skip to content

Commit

Permalink
[PERF] Batch RecordArrays (#4849)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner authored Mar 14, 2017
1 parent 4cf156b commit e44824c
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 @@ -126,7 +126,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 @@ -266,6 +266,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 @@ -947,8 +961,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 e44824c

Please sign in to comment.