forked from 0x1428571429/microfrontend-base-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStore.js
More file actions
28 lines (23 loc) · 714 Bytes
/
Store.js
File metadata and controls
28 lines (23 loc) · 714 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
import { createStore, combineReducers } from 'redux'
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 to(state = initialState, action) {
if (action.type !== 'to' && action.owner !== 'base') return { ...state, path: action.path }
history.replace(action.path)
return { ...state, path: action.path }
}
export const storeInstance = createStore(combineReducers({ namespace: () => 'base', render, to }))
export { history }