-
Notifications
You must be signed in to change notification settings - Fork 107
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
failType not triggered for rejected promise #147
Comments
If you want to automatically dispatch then you need to set the dispatchReturn option to true, set a success action type too and remove dispatch and done from the process arguments. |
Thanks for responding @cesarp. Yes, @ak99372 when using the original callback mode (with The newer async auto dispatch mode (using the So you can switch into this mode by omitting the extra arguments (dispatch and done) or by specifying dispatchReturn option to true. I usually just omit the arguments so it is clear I don't need to do anything with them. You code would look like this const myLogic= createLogic({
type: "FETCH",
processOptions: {
failType: "FETCH_ERROR"
},
process({ getState }) {
const promise = fnThatReturnsPromise();
return promise;
}
}); OR using async/await style const myLogic= createLogic({
type: "FETCH",
processOptions: {
failType: "FETCH_ERROR"
},
async process({ getState }) {
const result = await fnThatReturnsPromise();
return result;
}
}); And if you had thrown this would properly be decorated by failType const myLogic= createLogic({
type: "FETCH",
processOptions: {
failType: "FETCH_ERROR"
},
async process({ getState }) {
throw new Error('myerror'); // will be decorated by failType
}
}); |
Thank you both for reply and indeed adding
Hope that helps with some usability feedback. |
I went over the API documentation and the setup of failType seems straight forward yet I can't make it work with async logic...
I also read that "The process hook is run asynchronously" so I should be able to write it like this (though the result is the same)
My issues:
The text was updated successfully, but these errors were encountered: