Skip to content

Commit

Permalink
move run.join usage up to store.push
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Dec 9, 2016
1 parent cd4d91d commit c2b5fb9
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2275,37 +2275,36 @@ Store = Service.extend({
*/
_push(data) {
let token = heimdall.start('store._push');
let included = data.included;
let i, length;
let internalModelOrModels = this._backburner.join(() => {
let included = data.included;
let i, length;

if (included) {
for (i = 0, length = included.length; i < length; i++) {
this._pushInternalModel(included[i]);
if (included) {
for (i = 0, length = included.length; i < length; i++) {
this._pushInternalModel(included[i]);
}
}
}

if (Array.isArray(data.data)) {
length = data.data.length;
let internalModels = new Array(length);
if (Array.isArray(data.data)) {
length = data.data.length;
let internalModels = new Array(length);

for (i = 0; i < length; i++) {
internalModels[i] = this._pushInternalModel(data.data[i]);
for (i = 0; i < length; i++) {
internalModels[i] = this._pushInternalModel(data.data[i]);
}
return internalModels;
}
heimdall.stop(token);
return internalModels;
}

if (data.data === null) {
heimdall.stop(token);
return null;
}

assert(`Expected an object in the 'data' property in a call to 'push' for ${data.type}, but was ${typeOf(data.data)}`, typeOf(data.data) === 'object');
if (data.data === null) {
return null;
}

let internalModel = this._pushInternalModel(data.data);
assert(`Expected an object in the 'data' property in a call to 'push' for ${data.type}, but was ${typeOf(data.data)}`, typeOf(data.data) === 'object');

return this._pushInternalModel(data.data);
});
heimdall.stop(token);
return internalModel;
return internalModelOrModels;
},

_hasModelFor(modelName) {
Expand Down Expand Up @@ -2344,9 +2343,7 @@ Store = Service.extend({
// Actually load the record into the store.
let internalModel = this._load(data);

this._backburner.join(() => {
this._backburner.schedule('normalizeRelationships', this, this._setupRelationships, internalModel, data);
});
this._backburner.schedule('normalizeRelationships', this, this._setupRelationships, internalModel, data);

return internalModel;
},
Expand Down

0 comments on commit c2b5fb9

Please sign in to comment.