UNPKG

@redux-ts-starter-kit/slice

Version:
40 lines (39 loc) 1.11 kB
import type { AnyAction } from './types'; import type { CasesBase, Reducer } from './slice'; /** * @description Input for the createReducer utility * * @export * @interface CreateReducer * @template SS - The [State] interface */ export interface CreateReducer<S = any, C extends CasesBase<S> = any> { /** * The initial State, same as in standard reducer * * @type {S} * @memberof CreateReducer */ initialState: S; /** * @description - An object whose methods represent the cases the generated reducer handles, * can be thought of as the equivalent of [switch-case] statements in a standard reducer. * * @type {ReducerMap<SS, any>} * @memberof CreateReducer */ cases: C; } /** * Creates a simple reducer * * @export * @template S - The [State] * @param {CreateReducer<S>} { * initialState, * cases, * slice = '', * } * @returns */ export declare function createReducer<S, C extends CasesBase<S> = CasesBase<S>>({ initialState, cases, }: CreateReducer<S, C>): Reducer<S, AnyAction>;