ngrx-immer
Version:
Immer wrappers around NgRx methods createReducer, on, and ComponentStore
17 lines (16 loc) • 801 B
TypeScript
import { Action, ReducerTypes, ActionReducer, ActionCreator, ActionType } from '@ngrx/store';
import { Draft } from 'immer';
/**
* An immer reducer that allows a void return
*/
export interface ImmerOnReducer<State, AC extends ActionCreator[]> {
(state: Draft<State>, action: ActionType<AC[number]>): void;
}
/**
* Immer wrapper around `on` to mutate state
*/
export 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
*/
export declare function createImmerReducer<State, A extends Action = Action>(initialState: State, ...ons: ReducerTypes<State, any>[]): ActionReducer<State, A>;