Skip to content

make DS.ManyArray lazy - #4600

Merged
igorT merged 1 commit into
warp-drive-data:masterfrom
tchak:lazy-many-arrays
Oct 21, 2016
Merged

make DS.ManyArray lazy#4600
igorT merged 1 commit into
warp-drive-data:masterfrom
tchak:lazy-many-arrays

Conversation

@tchak

@tchak tchak commented Oct 19, 2016

Copy link
Copy Markdown
Contributor

This is mostly @igorT typing on my keyboard :)

@igorT

igorT commented Oct 19, 2016

Copy link
Copy Markdown
Contributor

We should add a test that verifies it is indeed lazy

HasManyReference.prototype.push = function(objectOrPromise) {
return Ember.RSVP.resolve(objectOrPromise).then((payload) => {
return resolve(objectOrPromise).then((payload) => {
var array = payload;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should likely return if the HasManyReference is destroyed by now (assuming it can be destroyed)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have eventually the same problem with belongsTo. I think it's best to create an issue and make a separate PR to fix it (if it's really a problem). I have not changed anything significant in this PR regarding references.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, open an issue and link back here, so we can address.

@igorT

igorT commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

Based on measurement this leads to a 15%+ speed improvement when loading hasMany relationships. (one of the scenarios with 5 hasMany's showed a 50% improvement)

@tchak

tchak commented Oct 21, 2016

Copy link
Copy Markdown
Contributor Author

@igorT test added

@igorT
igorT merged commit 4463dd4 into warp-drive-data:master Oct 21, 2016
@stefanpenner

Copy link
Copy Markdown
Contributor

This causes a perf issue and breaking apps using glimmer (which detects this scenario)

Specifically, when a relationship is lazily consumed it should not have side-affects, such as invalidating itself.

POC fix to unblock: #4643, but working on a more comprehensive one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants