-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathstore.js
More file actions
61 lines (45 loc) · 1.78 KB
/
store.js
File metadata and controls
61 lines (45 loc) · 1.78 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import isBrowser from 'is-in-browser';
import {decode} from '@tuxsudo/b64';
import { routerReducer as routing } from 'react-router-redux';
import {ALLOW_REDUX_DEV_TOOLS} from './env';
import system, * as fromSystem from './reducers/system';
import nav, * as fromSiteNav from './reducers/site-nav';
import pageMeta, * as fromPageMeta from './reducers/page-meta';
// create the master reducer
const rootReducer = combineReducers({nav, system, routing, pageMeta});
// Reexport scoped selectors here:
export const selectSiteNav = (state) => (
fromSiteNav.selectSiteNav(state.nav)
);
export const selectHTTPResponseCode = (state) => (
fromSystem.selectHTTPResponseCode(state.system)
);
export const selectAllApplicationErrors = (state) => (
fromSystem.selectAllApplicationErrors(state.system)
);
export const selectApplicationError = (state, id) => (
fromSystem.selectApplicationError(state.system, id)
);
export const selectPageMeta = (state) => (
fromPageMeta.selectPageMeta(state.pageMeta)
);
export const selectPageTitle = (state) => (
fromPageMeta.selectPageTitle(state.pageMeta)
);
export const selectMetaTags = (state) => (
fromPageMeta.selectMetaTags(state.pageMeta)
);
// determine initial state
const initialState = isBrowser && window.__INITIAL_STATE__
? JSON.parse( decode(window.__INITIAL_STATE__) )
: {};
const reduxMiddleware = compose(
applyMiddleware(thunk),
isBrowser && ALLOW_REDUX_DEV_TOOLS==="1" && typeof window.devToolsExtension !== "undefined"
? window.devToolsExtension()
: f => f
);
// export a store creator factory with initial state if present...
export default () => createStore( rootReducer, initialState, reduxMiddleware );