-
-
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
Get firstObject/lastObject notification only when cached #5591
Get firstObject/lastObject notification only when cached #5591
Conversation
Is this related to #5379? |
a9a3510
to
0994684
Compare
Yes, it is basically the same thing. I have updated the PR with a test and a variation of the #5379 mentioned diff https://gist.github.com/mmun/877bad33158578a8609b. The cache checks should IMO however do only presence check, not using the cache value (compare with |
0994684
to
d42d433
Compare
@mmun ping |
d42d433
to
70d6f47
Compare
Hey, is there anything that blocks this from merging? |
Looks like this needs another rebase. I'll to mention this in the upcoming meeting to see if folks are generally 👍 or 👎... |
70d6f47
to
53b58ce
Compare
rebased... |
@opichals the cache check is not correct, we should also provide in meta an isCached method, so this mistake isn't copied anymore. The idea should be if we don't think it is safe to recheck, we just fire the change event. It should not be that people can override the firing of the event, it should just be to override rechecking it against objectAt(), we could even limit the recheck to just the NativeArray mixin |
@rwjblue I've reviewed it now, what I mentioned needs to be addressed before merging. |
f837d94
to
5c712ba
Compare
Did a quick |
5c712ba
to
72d0c3e
Compare
☔ The latest upstream changes (presumably #12942) made this pull request unmergeable. Please resolve the merge conflicts. |
9ed61a7
to
1dc8e16
Compare
Firing the rebased |
@opichals I agree it should have the same lazy behavior as a CP and not notify if nothing has actually computed firstObject. I agree with the test. What I'm against is making this hook public API so that it is ok to prevent a change event even when something has consumed firstObject or lastObject. Checking for undefined is actually a presence check, undefined is cached using a special internal value since If the test and fix were separate from trying to introduce a new public API, I would be happy to merge this. /cc @mmun @rwjblue |
601c10b
to
fe2c05c
Compare
@krisselden Thanks, agreed. Updated and rebased. |
var meta = peekMeta(this); | ||
var cache = meta && meta.readableCache(); | ||
if (cache) { | ||
if (cache['firstObject'] !== undefined && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use 2 space indentation, the 4 spaces here (and below) are causing the build failures).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @opichals (I think that this is the main blocker).
fe2c05c
to
818081d
Compare
818081d
to
e5959e2
Compare
e5959e2
to
7bbbd6a
Compare
@opichals Tests seem to be failing here, could you fix those? |
It looks like a circular reference issue with the module imports. |
☔ The latest upstream changes (presumably #13658) made this pull request unmergeable. Please resolve the merge conflicts. |
i'll take this |
rebase and tracking this over here -> #14493 |
Created Em.Array#arrayFirstLastObjectChange abstraction in order to be able to override the Em.Array#firstObject/lastObject notification implementation which by default calls #objectAt(0) and #objectAt(length-1).
These calls are not optimal in case of e.g. sparse RecordArrays which would trigger unnecessary content[index] requests.
Consider an example of using Ember.ListView which only pulls the rendered items out of the content array. In case the content is an ArrayController which dynamically loads items as rendered the Em.Array would actually request the index of 0 and length-1 even in cases where those index content items are not to be rendered at all and therefore trigger unnecessary store layer roundtrips.