UNPKG

1.06 kBTypeScriptView Raw
1/**
2 * A function which takes a State S and performs a transformation into a new state. The state mutation must be pure.
3 * @returns A new state of type S
4 */
5export declare type StateMutation<S> = (state: S) => S;
6/**
7 * A reducer takes a state S, a payload P, applies a transformation using the payload to the state and
8 * returns a new State. Reducers must be pure.
9 */
10export declare type Reducer<S, P = void> = (state: S, actionPayload: P) => S;
11/**
12 * Type of a "cleanup" state object that will be set to the slice when the sliceStore gets destroyed
13 *
14 * The special string "undefined" means the slice prop should be set to undefined (but the props remains there)
15 * Using "delete" will remove the whole prop key from the state object (use this to leave no traces)
16 */
17export declare type CleanupState<K> = K | null | "undefined" | "delete";
18export interface ActionDispatch<P> {
19 actionName: string;
20 actionPayload: P;
21}
22export interface StateChangeNotification<S = any> {
23 actionName: string | undefined;
24 actionPayload: any;
25 newState: S;
26}