@fluentui/state
Version:
A set of utils to create framework agnostic and reusable state managers
21 lines (20 loc) • 1.2 kB
TypeScript
export declare type AnyAction = (...args: any[]) => void;
export declare type AnyActions = Record<string, AnyAction>;
export declare type Middleware<State, Actions> = (prevState: State, nextState: State, actions: Actions) => Partial<State>;
export declare type SideEffect<State> = (prevState: State, nextState: State) => void;
export declare type EnhancedAction<State, Actions extends AnyActions, Action extends AnyAction = AnyActions[keyof AnyActions]> = (...args: Parameters<Action>) => (state: State, actions: Actions) => Partial<State> | void;
export declare type EnhancedActions<State, Actions extends AnyActions> = {
[Name in keyof Actions]: EnhancedAction<State, Actions, Actions[Name]>;
};
export declare type ManagerConfig<State, Actions extends AnyActions> = {
actions: EnhancedActions<State, Actions>;
debug?: boolean;
middleware?: Middleware<State, Actions>[];
state?: Partial<State>;
sideEffects?: SideEffect<State>[];
};
export declare type ManagerFactory<State, Actions extends AnyActions> = (config: ManagerConfig<State, Actions>) => Manager<State, Actions>;
export declare type Manager<State, Actions> = {
readonly state: State;
actions: Actions;
};