-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreduceMap.ts
More file actions
23 lines (20 loc) · 787 Bytes
/
reduceMap.ts
File metadata and controls
23 lines (20 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { INIT, reduceInit } from './init'
import type { ReduceFunc } from './reducer'
import { REMOVE, reduceRemove } from './remove'
import { reduceSetData, SET_DATA } from './setData'
import { reduceSetDefaultID, SET_DEFAULT_ID } from './setDefaultID'
import type { State } from './stateTypes'
export interface ReduceMap<S extends State> {
[type: string]: ReduceFunc<S>
}
// default reduceMap
export const DEFAULT_REDUCE_MAP: <S extends State>() => ReduceMap<S> = () => ({
// @ts-expect-error baseAction in ReduceMap
[INIT]: reduceInit,
[SET_DATA]: reduceSetData,
[REMOVE]: reduceRemove,
// setDefaultID.
// Typically we don't need this in programming.
// The defaultID is automatically determined if defaultID is not set.
[SET_DEFAULT_ID]: reduceSetDefaultID,
})