-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.js
42 lines (38 loc) · 990 Bytes
/
store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunkMiddleware from 'redux-thunk';
import _ from 'lodash';
import actionTypes from './lib/actionTypes';
const theInitialState = {
tables: [],
displayTableId: null,
dragTableId: null,
};
export const reducer = (state = exampleInitialState, action) => {
switch (action.type) {
case actionTypes.UPDATE_TABLES:
return {
...state,
tables: action.tables,
};
case actionTypes.UPDATE_DISPLAY:
return {
...state,
displayTableId: action.displayTableId,
};
case actionTypes.UPDATE_DRAG:
return {
...state,
dragTableId: action.dragTableId,
};
default:
return state;
}
};
export function initializeStore(initialState = theInitialState) {
return createStore(
reducer,
initialState,
composeWithDevTools(applyMiddleware(thunkMiddleware)),
);
}