-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Directly reloading a hasMany with links should trigger only one request #2384
Directly reloading a hasMany with links should trigger only one request #2384
Conversation
@@ -114,6 +117,9 @@ export default RecordArray.extend({ | |||
@public | |||
*/ | |||
reload: function() { | |||
if (this._loadingPromise) { |
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.
I feel like this should be handled in the relationship, as we already keep lots of loading data there.
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.
@igorT Let me now what do you think about it, since I also reset the isLoaded state when reloading. (It was not the case before this commit, and one assert failed) |
any expectations on when this can be merged ? |
@sol1dus I have no idea. @igorT I will gladly rebase if needed 😄 |
@igorT I'm sorry to ping you again, but I don't like to keep WIP open too long. Is this behavior still wanted ? |
@sly7-7 curious on the status of this, thanks! |
@bmac Is this something to be discussed during a core meeting ? |
There's a rebase branch of this over at https://github.com/emberjs/data/tree/rebase-2384. We need to update some of the tests and have a better way of inspecting the state of promises to know if it's fulfilled or not to land this. |
@wecc thanks for keeping that alive :) I'm currently working on the rebase branch, trying to make the tests pass. |
@wecc I just updated this against the rebase branch, let me know if you think this is this kind of implementation you were waiting for :) |
It would be great to see this PR progress. I've rebased against master here: https://github.com/alisdair/data/tree/pr/2384 It's not clear from the title, but this also seems to fix the case where a hasMany with link fails to load, and reload() is called to try again. At the moment, if a hasMany with link fails to load, there's nothing that can be done to rectify the situation, as far as I can tell. |
@wecc Was that discussed during the meetings ? |
@sly7-7 I do not remember fully tbh. I think @igorT and @stefanpenner had a discussion regarding how to inspect the state of a promise but I'm unsure what was decided. |
@wecc or @sly7-7 what is the status on this pr. Is there a decision/insight needed from @igorT or @stefanpenner? |
@bmac, I think the point here is https://github.com/emberjs/data/pull/2384/files#diff-0c8d73828c8e0096b8bf3d5ef10cac5aR105, where we inspect if the promise is still pending or not. |
@@ -450,6 +450,81 @@ test("A hasMany relationship can be reloaded if it was fetched via ids", functio | |||
}); | |||
}); | |||
|
|||
test("A hasMany relationship can be reloaded even if it failed at the first time", function() { |
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.
"even if it failed at the first time" => "even if it failed the first time"
Thanks @sly7-7. I got @stefanpenner to look at that this morning and he said it looks good. Do you mind rebasing this pr? |
} | ||
}; | ||
run(function() { | ||
env.store.find('post', 1).then(async(function(post) { |
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.
do we actually need these asyncs? qunit supports promises, we merely need to return the promise chain. This will also improve error scenarios in the test suite..
I suspect on completion (in this case rejection) the _loadingPromise could just be removed, so future |
Technically, that means doing something like |
ya, potentially also on any completion. |
Ok, thanks for the review @stefanpenner 😄 |
Thanks @sly7-7. I'm in no runs to get anything in before the next release, so take your time. |
@sly7-7 Do you have time to rebase and squash this pr? |
@bmac sure, I will do it tonight :) |
Introducing a loading promise in the many relationship in order to keep track of its loading state.
@bmac Done 😄 |
…with-links Directly reloading a hasMany with links should trigger only one request
Thanks @sly7-7 |
Fixes #2379
cc/ @jcbvm @igorT