Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX backburner] Avoids spinning up unnecessary run loops via run.join #4698

Merged
merged 1 commit into from
Dec 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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