multiple dispatches inside fetch
walshe opened this issue · 6 comments
walshe commented
finally realised after anout 2 weeks that a return is needed on the last dispatch (if you have multiple dispatches) inside the fetch.
Why is this exactly ? might be no harm to put in the docs btw
`const redial = {
/**
-
this is triggered from server/index.js
*/
fetch: ({ dispatch, params: {filter} }) => {//get filter data dispatch(loadFilterData()) //kick off a default search return dispatch(loadUnlistedVins())
}
}`
walshe commented
example ?
EJIqpEP commented
Had the same problem. @hnq90 just use Promise.all
const redial = {
fetch: ({ dispatch }) => Promise.all([
dispatch(fetchCurrentUser()),
dispatch(fetchCategories())
])
}
ngocketit commented
So does this mean dispatch
needs to return a Promise
? Does it work with redux-api-middleware
? I'm thinking about switching over to redial
ngocketit commented
Oh yes, the promise is stated in the doc. Any one having this work with redux-api-middleware
?