forked from mathias5r/rn-heartbeat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.js
43 lines (35 loc) · 1.03 KB
/
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
43
import { combineReducers, createStore, applyMiddleware } from 'redux';
import { createAction, handleActions } from 'redux-actions';
import logger from 'redux-logger';
const appInitialState = {
isServiceRunning: false,
phoneNumber: '+40742644552'
};
const START_SERVICE = 'START_SERVICE';
const STOP_SERVICE = 'STOP_SERVICE';
const SET_PHONE_NUMBER = 'SET_PHONE_NUMBER';
export const startService = createAction(START_SERVICE);
export const stopService = createAction(STOP_SERVICE);
export const setPhoneNumber = createAction(SET_PHONE_NUMBER);
const App = handleActions(
{
[START_SERVICE]: (state) => ({
...state,
isServiceRunning: true
}),
[STOP_SERVICE]: (state) => ({
...state,
isServiceRunning: false
}),
[SET_PHONE_NUMBER]: (state, action) => ({
...state,
phoneNumber: action.payload
})
},
appInitialState
);
const rootReducer = combineReducers({
App
});
const configureStore = () => createStore(rootReducer, applyMiddleware(logger));
export const store = configureStore();