You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently forceRequest has no return value, but I think it would be useful if it returned a promise (could handle fulfillment/rejection similarly to Promise.all, but the actual fulfillment/rejection values are not too important for the use case I have).
Use case: I'm using redux-query with a React Native project, and I have a component that is connectRequested with one query. I want to implement refresh functionality via https://facebook.github.io/react-native/docs/refreshcontrol.html, which takes a refreshing prop to determine if it should show the spinner above the top of the view. I can't just use the result of isPending for the query as the value for refreshing, because then the spinner will show when the component first mounts and performs the initial data fetch (and the rest of the view gets pushed down to make room for the spinner for no reason). I want to do something like:
I do have a workaround, which is manually wiring up the request I want to make on refresh via mapDispatchToProps and calling that instead of forceRequest, but that makes me do a lot of the work that connectRequest is supposed to save me from doing, so I was wondering if it'd be useful for forceRequest to return a promise.
The text was updated successfully, but these errors were encountered:
@soulostar Makes sense to me. Perhaps an array of promises since you can make multiple requests with connectRequest and forceRequest currently re-triggers all of them? You'd be able to use Promise.all to handle the case when all have completed.
I'd accept a PR with this change if you're interested in making one!
We decided not to change the API for forceRequest. We are moving forward with a new hooks API (see #129 for the PR) that should help with this use case.
Currently
forceRequest
has no return value, but I think it would be useful if it returned a promise (could handle fulfillment/rejection similarly to Promise.all, but the actual fulfillment/rejection values are not too important for the use case I have).Use case: I'm using redux-query with a React Native project, and I have a component that is
connectRequest
ed with one query. I want to implement refresh functionality via https://facebook.github.io/react-native/docs/refreshcontrol.html, which takes arefreshing
prop to determine if it should show the spinner above the top of the view. I can't just use the result ofisPending
for the query as the value forrefreshing
, because then the spinner will show when the component first mounts and performs the initial data fetch (and the rest of the view gets pushed down to make room for the spinner for no reason). I want to do something like:I do have a workaround, which is manually wiring up the request I want to make on refresh via
mapDispatchToProps
and calling that instead offorceRequest
, but that makes me do a lot of the work thatconnectRequest
is supposed to save me from doing, so I was wondering if it'd be useful forforceRequest
to return a promise.The text was updated successfully, but these errors were encountered: