|
@@ -1,47 +1,21 @@
|
|
import { Map } from "immutable";
|
|
import { Map } from "immutable";
|
|
|
|
|
|
import {
|
|
import {
|
|
- TEST_ACTION,
|
|
|
|
- TEST_ASYNC_ACTION_START,
|
|
|
|
- TEST_ASYNC_ACTION_ERROR,
|
|
|
|
- TEST_ASYNC_ACTION_SUCCESS,
|
|
|
|
|
|
+ INCREMENT,
|
|
} from "actions/app";
|
|
} from "actions/app";
|
|
|
|
|
|
const initialState = Map({
|
|
const initialState = Map({
|
|
counter: 0,
|
|
counter: 0,
|
|
- asyncLoading: false,
|
|
|
|
- asyncError: null,
|
|
|
|
- asyncData: null,
|
|
|
|
});
|
|
});
|
|
|
|
|
|
const actionsMap = {
|
|
const actionsMap = {
|
|
- [TEST_ACTION]: (state) => {
|
|
|
|
|
|
+ [INCREMENT]: (state) => {
|
|
const counter = state.get("counter") + 1;
|
|
const counter = state.get("counter") + 1;
|
|
|
|
|
|
return state.merge({
|
|
return state.merge({
|
|
counter,
|
|
counter,
|
|
});
|
|
});
|
|
},
|
|
},
|
|
-
|
|
|
|
- // Async action
|
|
|
|
- [TEST_ASYNC_ACTION_START]: (state) => {
|
|
|
|
- return state.merge({
|
|
|
|
- asyncLoading: true,
|
|
|
|
- asyncError: null,
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- [TEST_ASYNC_ACTION_ERROR]: (state, action) => {
|
|
|
|
- return state.merge({
|
|
|
|
- asyncLoading: false,
|
|
|
|
- asyncError: action.data,
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- [TEST_ASYNC_ACTION_SUCCESS]: (state, action) => {
|
|
|
|
- return state.merge({
|
|
|
|
- asyncLoading: false,
|
|
|
|
- asyncData: action.data,
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
};
|
|
};
|
|
|
|
|
|
export default function reducer(state = initialState, action = {}) {
|
|
export default function reducer(state = initialState, action = {}) {
|