-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
models.ts
38 lines (30 loc) · 967 Bytes
/
models.ts
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
export interface Action {
type: string;
}
export type TypeId<T> = () => T;
export type InitialState<T> = Partial<T> | TypeId<Partial<T>> | void;
export interface ActionReducer<T, V extends Action = Action> {
(state: T | undefined, action: V): T;
}
export type ActionReducerMap<T, V extends Action = Action> = {
[p in keyof T]: ActionReducer<T[p], V>
};
export interface ActionReducerFactory<T, V extends Action = Action> {
(
reducerMap: ActionReducerMap<T, V>,
initialState?: InitialState<T>
): ActionReducer<T, V>;
}
export type MetaReducer<T, V extends Action = Action> = (
reducer: ActionReducer<T, V>
) => ActionReducer<T, V>;
export interface StoreFeature<T, V extends Action = Action> {
key: string;
reducers: ActionReducerMap<T, V> | ActionReducer<T, V>;
reducerFactory: ActionReducerFactory<T, V>;
initialState?: InitialState<T>;
metaReducers?: MetaReducer<T, V>[];
}
export interface Selector<T, V> {
(state: T): V;
}