Comparing version 0.6.1 to 0.6.2
{ | ||
"name": "redux-arc", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Abstraction layer to simplify rest api calls in redux", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -16,3 +16,3 @@ <img src="https://github.com/viniciusdacal/redux-arc/blob/master/arc-64.png?raw=true" height="64" /> | ||
## Creators and types are generated by a config | ||
## Action creators and types generated by a config | ||
@@ -25,6 +25,7 @@ ```js | ||
add: null, | ||
reset: null | ||
}); | ||
``` | ||
## Create reducers using createReducers and types: | ||
## Create reducers reusing types and without switch cases: | ||
@@ -36,4 +37,13 @@ ```js | ||
const INITIAL_STATE = []; | ||
const onAdd = (state, action) => [ | ||
...state, | ||
action.payload, | ||
]; | ||
const onReset = () => INITIAL_STATE; | ||
const HANDLERS = { | ||
[types.ADD]: (state, action) => [...state, action.payload] | ||
[types.ADD]: onAdd, | ||
[types.onReset]: onReset, | ||
}; | ||
@@ -49,9 +59,16 @@ | ||
const payload = { | ||
name: 'Luke', | ||
master: 'Yoda', | ||
}; | ||
const payload = { name: 'Luke' }; | ||
const meta = { foo: 'bar' }; | ||
dispatch(creators.add(payload, meta)) | ||
dispatch(creators.add(payload, meta)); | ||
/* | ||
{ | ||
type: 'JEDI_ADD', | ||
payload: { name: 'luke' }, | ||
meta: { foo: 'bar' }, | ||
} | ||
*/ | ||
dispatch(creators.reset()); | ||
// { type: 'JEDI_RESET' } | ||
``` | ||
@@ -73,10 +90,10 @@ | ||
``` | ||
> createActions creates both, regular and async actions. Async types has REQUEST and RESPONSE type, respectively to when a request starts and when it finishes. | ||
> createActions creates both, regular and **Async Actions**. Async types has **REQUEST** and **RESPONSE** type, respectively to when a request starts and when it finishes. | ||
# Getting started | ||
#Getting started | ||
```bash | ||
yarn add redux-arc | ||
``` | ||
or | ||
@@ -83,0 +100,0 @@ |
130774
451