-
Notifications
You must be signed in to change notification settings - Fork 28
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
fetch() caches previous responses, returns bad results #33
Comments
See under the "Links" section: https://weluse.github.io/hyperagent/:
root.links['ht:users'].fetch().then(...);
// Enforce a refresh.
root.links['ht:users'].fetch({ force: true }).then(...); |
Even when a refresh is forced on the fetch call, the results are cached in the case of array results. The example I provided can be mimicked with the force option set below: ## should return 4 results
some_link_resource.fetch({force:true}) ->
network response: [ object1, object2, object3, object4 ]
fetch results: [ object1, object2, object3, object4 ]
## should return 2 results
some_other_link_resource.fetch({force:true}) ->
network response: [ object5, object6 ]
fetch results: [ object5, object6, object3, object4 ]
## should return an empty array
some_third_link_resource.fetch({force:true}) ->
network response: [ ]
fetch results: [ object5, object6, object3, object4 ] Again, the fact that network calls are being sent out and received shows that the links should not be caching previous results, since the links are each separate calls, not successive calls on the same link resource. The However, in the case of pure object responses, the behavior is as expected. some_object_link_resource.fetch({force:true}) ->
network response: { key1: object1, key2: object2, key3: object3 }
fetch results: { key1: object1, key2: object2, key3: object3 }
some_other_object_link_resource.fetch({force:true}) ->
network response: { key1: object1, key2: object2 }
fetch results: { key1: object1, key2: object2 }
some_third_object_link_resource.fetch({force:true}) ->
network response: { }
fetch results: { } |
I suggest reopening this. |
When an array is returned from a fetch() call, any consecutive fetch() calls use the same (cached) array as a response, overwrite it with any incoming indices, and returns the resulted array to the caller.
e.g.
The text was updated successfully, but these errors were encountered: