Skip to content

Commit

Permalink
Merge pull request #5151 from emberjs/reduce-duplicate-signals-to-rec…
Browse files Browse the repository at this point in the history
…ord-array-manager-on-record-push

[CLEANUP] PERF prevent duplicate recordArrayManager signals on push o…
  • Loading branch information
stefanpenner authored Aug 30, 2017
2 parents 441e48c + 01113a0 commit 7a7bafa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
22 changes: 0 additions & 22 deletions addon/-private/system/model/internal-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ export default class InternalModel {

resetRecord() {
this._record = null;
this.dataHasInitialized = false;
this.isReloading = false;
this.error = null;
this.currentState = RootState.empty;
Expand Down Expand Up @@ -598,18 +597,6 @@ export default class InternalModel {
if (this.hasRecord) {
this._record._notifyProperties(changedKeys);
}
this.didInitializeData();
}

becameReady() {
this.store.recordArrayManager.recordWasLoaded(this);
}

didInitializeData() {
if (!this.dataHasInitialized) {
this.becameReady();
this.dataHasInitialized = true;
}
}

get isDestroyed() {
Expand Down Expand Up @@ -644,7 +631,6 @@ export default class InternalModel {
*/
loadedData() {
this.send('loadedData');
this.didInitializeData();
}

/*
Expand Down Expand Up @@ -791,14 +777,6 @@ export default class InternalModel {
this.didCleanError();
}

//Eventually rollback will always work for relationships
//For now we support it only out of deleted state, because we
//have an explicit way of knowing when the server acked the relationship change
if (this.isDeleted()) {
//TODO: Should probably move this to the state machine somehow
this.becameReady();
}

if (this.isNew()) {
this.removeFromInverseRelationships(true);
}
Expand Down
8 changes: 7 additions & 1 deletion addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2017,9 +2017,15 @@ Store = Service.extend({
heimdall.increment(_load);
let internalModel = this._internalModelForId(data.type, data.id);

let isUpdate = internalModel.currentState.isEmpty === false;

internalModel.setupData(data);

this.recordArrayManager.recordDidChange(internalModel);
if (isUpdate) {
this.recordArrayManager.recordDidChange(internalModel);
} else {
this.recordArrayManager.recordWasLoaded(internalModel);
}

return internalModel;
},
Expand Down

0 comments on commit 7a7bafa

Please sign in to comment.