-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pushing to an arrayProxy triggers calls to objectAtContent on the content array #5379
Comments
the proxies are currently very eager. @mmun has some WIP i believe on making them lazy |
Seems like we just want to repeat the |
Tried that, broke tests, might investigate later. This bug will make lazy hasMany's a bit more annoying because they will eagerly fetch first/last records |
I agree with @igorT. |
The problem is that even if no one is watching you need to clear the cache if |
Only if the cache has been set though. I think ignoring it if the cache isn't set would cover lots of cases |
Yeah. Alternatively, |
I implemented your suggestion (link to diff) and the tests pass. It is pretty hacky though. |
I'll turn the jsbin into a real test tomorrow |
@mmun we need to make lazyGet a first class thing for alias descriptor and to work with paths. we could also use it here. I don't like things reaching into meta directly and making assumptions, it makes it hard to change stuff later. /cc @stefanpenner |
I'm also uncertain that Ember Data doing ajax as a side effect of get() is good design. I can see get() returning a promise, and you having to explicitly load data you want, but I think we maybe over relying on the lazy computation of CPs, and unexpected ajax as a consequence seems a little steep. |
Want to add a reference to #5289 as I think alias should just forward lazyGet() to a Ember.lazyGet(obj, propPath) and for desc to have desc.lazyGet(obj, key), then you can just do lazyGet(content, 'firstObject') |
|
Thats how it works now. Not sure what you propose as the alternative design |
First step seems like allowing array proxies to be lazier |
I've just applied the diff that @mmun links on #5379 (comment) and it fixed the problem. [edit] You can check the tests at https://github.com/locks/data/blob/async-has-many/packages/ember-data/tests/integration/relationships/async_has_many_test.js |
@mmun: should that patch become a PR? |
I have put together I hope a valid PR: #5591. |
Closing in favor of the PR |
If you have two arrayProxies, pushing to the top most proxy triggers calls to
objectAtContent
on the child proxy:http://emberjs.jsbin.com/samexo/1/edit
Seems like pushing objects shouldn't cause them to be accessed. In fact, only the first and last objects get accessed, due to this check:
https://github.com/emberjs/ember.js/blob/master/packages/ember-runtime/lib/mixins/array.js#L425
The text was updated successfully, but these errors were encountered: