ngrx-immer
Version:
Immer wrappers around NgRx methods createReducer, on, and ComponentStore
21 lines (18 loc) • 854 B
TypeScript
import { ActionCreator, ActionType, Action, ReducerTypes, ActionReducer } from '@ngrx/store';
import { Draft } from 'immer';
/**
* An immer reducer that allows a void return
*/
interface ImmerOnReducer<State, AC extends ActionCreator[]> {
(state: Draft<State>, action: ActionType<AC[number]>): void;
}
/**
* Immer wrapper around `on` to mutate state
*/
declare function immerOn<State, Creators extends ActionCreator[]>(...args: [...creators: Creators, reducer: ImmerOnReducer<State extends infer S ? S : never, Creators>]): ReducerTypes<State, Creators>;
/**
* Immer wrapper around `createReducer` to mutate state
*/
declare function createImmerReducer<State, A extends Action = Action>(initialState: State, ...ons: ReducerTypes<State, any>[]): ActionReducer<State, A>;
export { createImmerReducer, immerOn };
export type { ImmerOnReducer };