UNPKG

combine-action-reducer

Version:

create action creator and reducer with one action-reduer

22 lines (21 loc) 853 B
import { ActionReducer } from "./interface"; declare type getObjMap<R> = R extends ActionReducer<any, infer ObjMap> ? ObjMap : "Error at getObjMap"; declare type GetCombineObjMap<R> = R extends { [x: string]: ActionReducer<any, any>; } ? { [x in keyof R]: getObjMap<R[x]>; } : "Error at GetCombineObjMap"; declare type getState<R> = R extends ActionReducer<infer state, any> ? state : "Error at getState"; declare type GetCombineState<R> = R extends { [x: string]: ActionReducer<any, any>; } ? { [x in keyof R]: getState<R[x]>; } : "Error at GetCombineState"; /** * 合并多个ActionReducer; * @param combineObj 描述ActionReducer 如何合并 */ export declare function CombineActionReducer<R extends { [x: string]: ActionReducer<any, any>; }>(combineObj: R): ActionReducer<GetCombineState<R>, GetCombineObjMap<R>>; export {};