-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Call update model on first page load #89
Conversation
Weird! Looks good to me. @mike-north / @kellyselden / @mkorfmann can i get a second set of eyes? |
@@ -287,6 +289,9 @@ export default Ember.Mixin.create({ | |||
*/ | |||
updateInfinityModel(newObjects) { | |||
var infinityModel = this.get(this.get('_modelPath')); | |||
if (infinityModel === undefined || newObjects === 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.
It's sufficient to check for infinityModel being undefined here (or you need to add another test-case which explains the checking of newObjects).
Merging this PR would definitely resonate with me since the overwriting of 'updateInfinityModel' is encouraged in the README and it should work as expected for the first batch of records as well. But introducing a (or fixing a existing) hook which has no other side effects except of, well, being a hook, would be even better IMO. So while this fix definitely makes things work more as expected right now, I'm not sure whether encouraging patching of 'updateInfinityModel' is the ideal API for making changes to records after loading. |
How about introducing a new "first page" hook like afterInfinityModel or
|
I'm not sure if introducing a new hook is the right way either, maybe I should've put that more clearly. For me it feels like we only should need one hook to modify the records (or to do something else) after the model was loaded or am I missing something completely here? |
And 'updateInfinityModel' looks like it should be private API to me since it's needed after the initial batch was loaded. |
What would be really sweet IMO is if you could observe the infinityModel minId: Ember.computed('infinityModel.[]', function () {
return this.get('infinityModel.lastObject.id');
}) The change to the infinity model's array would happen in the same run loop |
Definitely a cool idea, but out of the scope of this PR I guess. So just for the record: I'd vote for merging this PR (just some minor nitpicking), since it makes overwriting After merging we should think about a more streamlined approach to the whole hook subject, but this is also out of the scope of this PR. |
@davidgoli - thoughts here? |
@hhff this PR fixes the bug, and also fulfills the promise of the documentation, which currently says: "You may override updateInfinityModel to customize how the route's model should be updated with new objects." But However, in a different PR, you raised an objection re: users who may be relying on the buggy behavior. Additionally, with this PR, users who override I think this PR is GTG. I have also left comments on #77, which I view as an acceptable alternative after some changes. But, I would want one or the other - and if #77 gets merged, I'd propose deprecating |
@davidgoli - I think we're going to go with #77 in favor of this - and deprecate Are you interested in making the deprecation change (we'll want to start using Ember.warn or something similar for #96 too)? I'm on holiday right now (hence the slow replies) 🐚 |
closing this in favor of #105 |
Fixes a bug in ember-infinity. See: #90
In short, there was no effective hook to update
boundParams
after the first page loads, but before the second page is requested. This PR fixes that.