4 ms·
Agreed, not sure what this gives over redux-promise-middleware, which lets you write things like: function myAction () { return { type: 'MY_A
by mikewhy 9y ago
Agreed, not sure what this gives over redux-promise-middleware, which lets you write things like:
function myAction () {
return {
type: 'MY_ACTION',
payload: someApiCall(),
}
}
And that will dispatch `MY_ACTION_PENDING`, then `MY_ACTION_FULFILLED` or `MY_ACTION_REJECTED`. Soon you'll be able to write your payload as an `async function`:
function myAction () {
return {
type: 'MY_ACTION',
async payload (dispatch) {
const apiResult = await someApiCall()
dispatch(anotherActionCauseWhyNot(apiResult))
return apiResult
}
}
}
I'm sure there's more to redux-saga, but this article doesn't do a great job of presenting that.
- cnp 9y agoThe library helps manage complex, concurrent in-flight workflows. Games are a great example of this, or something like a flight booking app that communicates with many different processes and servers and you need to ensure that fine-grained control is maintained at all times.