Redux Action Promise
documentation not complete yet
Middleware for wrapping redux actions with promise.
Allows component to detect dispatched action is finished or not.
resolve
and reject
are passed to action
object and you can call these after you have finished doing logic in actions or sagas.
Installation
npm i -S redux-action-promise
Set up
;...
Usage
Redux Action
// component.jsComponent ... onPress = async { this; await thisprops; this; } ... null login CustomComponent; // saga { ; ; // <-- resolve promise}
With Redux Form
// component.js; Component ... onPress = async { this; try await ; catch e console; this; } ... // saga; { try ; ; // <-- resolve promise catch e throw error: 'error occurred' }
Note
You can throw SubmissionError as above or you can use pass onError
to rfSubmitPromise
as below.
// component.jsonPress = async { this; try await ; catch e // throwing SubmissionError here won't work as SubmissionError need to be thrown inside handleSubmit function of redux-form console; this;}; // saga { try ; ; // <-- resolve promise catch e ; // <-- just reject error }