FSA Redux Thunk
Fork of redux-thunk
middleware that enforces
Flux Standard Actions.
Installation
npm install --save redux-thunk
or
yarn add fsa-redux-thunk
Then, to enable Redux Thunk, use applyMiddleware()
:
;;; // Note: this API requires redux@>=3.1.0const store = ;
redux-actions
FSA library
Usage with null
initial payload
Dispatching ; const fetchSomeApiSuccess = ;const fetchSomeApiFailure = ;const fetchSomeApiRequest = ;
Calling:
store;
will dispatch an FSA action with this shape first, then will execute the
payload creator function defined as the second argument to createAction
:
type: 'FETCH_SOME_API_REQUEST' payload: null
Dispatching WITH initial payload
In order to dispatch the initial request action (FETCH_SOME_API_REQUEST
in our example),
we must provide the value in the meta
field, as follows (the third argument to
createAction
):
; const fetchSomeApiSuccess = ;const fetchSomeApiFailure = ;const fetchSomeApiRequest = ;
Calling:
store;
will dispatch an FSA action with this shape first, then will execute the
payload creator function defined as the second argument to createAction
:
type: 'FETCH_SOME_API_REQUEST' payload: 'foobar'
License
MIT