redux-saga-promisify-actions
Motivation
When you make side effects in the saga, your component doesn't know about data flow, for this reason, this package makes a promise from your action creator like redux-thunk. It's makes possible use any form state management package without tears.
Installation
yarn add redux-saga-promisify-actions
Usage
Functions syncAction and asyncAction make one action creator and encapsulated types.
syncAction
// make action creator const getItem = getItemtype === 'ITEM/GET_ITEM' === type: 'ITEM/GET_ITEM' payload: data: 'data'
For making custom action structure use second param
const getItem = === type: 'ITEM/GET_ITEM' data: params: 1 2 params: 1 2
asyncAction
It's similar to syncAction but with types: request, success, failure
const getItem = getItemrequest === 'ITEM/GET_ITEM/REQUEST' getItemsuccess === 'ITEM/GET_ITEM/SUCCESS' getItemfailure === 'ITEM/GET_ITEM/FAILURE'
Wrap action into promise
Installation
In your create store function
; sagaMiddleware;
In your components:
; { thisprops // { data: "data" } ; } ... { ... } null getItems: MyComponent;