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
So a common pattern in redux-thunk land is to do something like:
// pseudo codeconstloadListingsWithFilter=(filter)=>(dispatch,getState)=>{// bailout early if the data is freshif(getTimeLastFetchedByFilter(getState(),filter)<15minutes){return;}// normal thunk stuff
...
}
How does this work with redux-pack?
The text was updated successfully, but these errors were encountered:
Using redux-pack should not prohibit you from using redux-thunk. (Hell, the readme seems to suggest adding both.) So you should feel free to use redux-pack for handling async actions, and redux-thunk for conditional actions.
For example:
constloadListings=(filter)=>{return{type: 'LOAD_LISTINGS',promise: Api.loadListings(filter),};};constloadListingsIfNeeded=(filter)=>(dispatch,getState)=>{// Bailout early if the data is freshif(!isLoadNeeded(getState(),filter)){return;}dispatch(loadListings(filter));};
Dropping down to redux-thunk is less than ideal, though. It's such a general API and allows devs/teams too much power to make bad decisions. It would be awesome to see something like this added to the API to handle this common scenario.
Would this library be open to adding a feature like this? I could submit a pull request to add it if there's openness. I've used a strategy like this before and found it very useful - it was used in most of our data-fetching scenarios.
So a common pattern in redux-thunk land is to do something like:
How does this work with
redux-pack
?The text was updated successfully, but these errors were encountered: