forked from 0x1428571429/microfrontend-submodule-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStore.js
More file actions
34 lines (28 loc) · 796 Bytes
/
Store.js
File metadata and controls
34 lines (28 loc) · 796 Bytes
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
import { createStore, combineReducers } from 'redux'
import menuDate from './common/menu'
import createHistory from 'history/createBrowserHistory'
const history = createHistory()
const initialState = {
refresh: 0
}
function render(state = initialState, action) {
switch (action.type) {
case 'REFRESH':
return {
...state,
refresh: state.refresh + 1
}
default:
return state
}
}
function menu() {
return menuDate
}
function to(state = initialState, action) {
if (action.type !== 'to' && action.owner !== 'list') return { ...state, path: '/' }
history.replace(action.path)
return { ...state, path: action.path }
}
export const storeInstance = createStore(combineReducers({ namespace: () => 'list', menu, render, to }))
export { history }