react-redux-dispatch-async
👉 REDUX middleware & HOOK 🎉 waiting async actions with SUFFIXES 👈
+------------------+
| ACTION_REQUESTED |----+
+------------------+ | +------------------+
+----->| ACTION_SUCCEEDED |
| +------------------+
|
| +--------------------+
+----->| ACTION_FAILED |
| +--------------------+
|
| +--------------------+
+----->| ACTION_CANCELED |
+--------------------+
Install
yarn add react-redux-dispatch-async
Features
Race condition to execute only the promise if multiple update occur in nearly same time
Hook give you helpful STATUS you can deal with into your own component
- ⏳
loading
: action start but not yet completed - 👏
success
: action completed, you can get the result - 😱
error
: action failed and you can get the error - 👎
timeout
: action not completed for tool long (ie. options?.timeoutInMilliseconds) - 👋
canceled
: action canceled - 😮
unknown
: should never happen
Examples
Usage
If you need more examples you can go to github or to codesandbox.
Configuration
Default suffixes
[...]_REQUESTED
[...]_SUCCEEDED
[...]_FAILED
[...]_CANCELED
Two functions
Configuration
dispatchAsyncMiddleware: c?: redux.Middleware
Type
// main hook
Hire an expert!
Looking for a ReactNative freelance expert with more than 14 years experience? Contact me from my website!