redux-api-actions
Utilities for redux-api-middleware, redux-actions and react-redux.
Table of Contents
Getting Started
Installation
redux-api-actions
is available on npm.
npm install --save redux-api-actions
Usage
Before use this library
- Setup up
redux-api-middleware
connect
a React component to a Redux store.
Defining the module
If you have something looks like this:
- constants
const namespace = 'count'; const NAMESPACE = namespace;const TYPE_COUNT = NAMESPACE;const TYPE_COUNT_REQUEST = `_REQUEST`;const TYPE_COUNT_SUCCESS = `_SUCCESS`;const TYPE_COUNT_FAILURE = `_FAILURE`; const endpoint = 'http://www.example.com/api/counter'
- redux-actions
;; const defaultState = counter: 10 ;const increment = ; const reducer = ;
- redux-api-middleware
;;; const incrementRemote = RSAA: endpoint: `/` method: 'GET' headers: 'Content-Type': 'application/json' credentials: 'same-origin' types: TYPE_COUNT_REQUEST TYPE_COUNT_SUCCESS TYPE_COUNT_FAILURE ; const reducer = ;
- react-redux
;;; const reduxActions = increment incrementRemote ; const mapStateToProps = store: storeNAMESPACE ;const mapDispatchToProps = actions: ;const Container = Root;
Then, you can merge them into this gist:
- redux-api-actions
;; const Container Reducer NAMESPACE = ;
Looks good, right?
Finally, merge your Reducer
into your redux
store as usual.
;const store = ;
Documentation
Hey, I'm no good at Writting. So, please help me do this. And please help me add the test case.
License
MIT