1 | const defaultOnUnknownActionTypeHandler = (state, action) => { |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
2 | const error = new Error('Unknown action type ' + action.type) |
||
3 | error.state = state |
||
4 | error.action = action |
||
5 | throw error |
||
6 | } |
||
7 | |||
8 | const createReducerViaMap = (map, initial, onUnknownActionType = defaultOnUnknownActionTypeHandler) => |
||
9 | (state, action) => { |
||
10 | if (typeof state === 'undefined') { |
||
11 | return initial |
||
12 | } else if (map.hasOwnProperty(action.type)) { |
||
13 | return map[action.type](state, action) |
||
14 | } else if (action.type === '@@redux/INIT') { |
||
15 | return initial |
||
16 | } else { |
||
17 | return onUnknownActionType(state, action) |
||
18 | } |
||
19 | } |
||
20 | |||
21 | createReducerViaMap.justReturnState = (state, action) => state |
||
0 ignored issues
–
show
|
|||
22 | |||
23 | export default createReducerViaMap |
||
24 |