redux-wrapper-extended
Version:
Short Cut Reducer definition.
57 lines (56 loc) • 2.48 kB
TypeScript
import { Reducer, AnyAction, Store, StoreEnhancer, Dispatch } from 'redux';
export interface ExtendedReducersMapObject {
[key: string]: Reducer<any> | ExtendedReducersMapObject;
}
export interface ReducerDict<S> {
[key: string]: Reducer<S>;
}
export declare type Handler<S> = (state: S, payload: any) => S;
export interface PropInfo {
rootProp: string;
lastProp: string;
beforeLastFunc: <S>(input: S) => any;
navigations: string[];
}
export interface ActionGeneratorDict {
[key: string]: (...args: any[]) => AnyAction;
}
export interface AnyActionDictionary {
[key: string]: (...args: any[]) => any;
}
export interface AnyProps {
[extraProps: string]: any;
}
declare class StoreWrapper<S> {
store: Store<S>;
combinedReducers: Reducer<S>;
constructor(reducers: ExtendedReducersMapObject | Reducer<S>, initialState: S | null, enhancer?: StoreEnhancer<S>);
dispatch(type: string, payload: any): {
type: string;
payload: any;
};
getStore(): Store<S>;
getCombinedReducers(): Reducer<S>;
}
declare let uselessReducer: <S>(state: S, action: AnyAction) => S | null;
declare let combineReducerWrapper: <S>(reducers: ExtendedReducersMapObject) => Reducer<S>;
declare class ReducerWrapper<S> {
defaultState: S | null;
funcs: ReducerDict<any>;
constructor(defaultState?: S);
withHandlersFromOtherReducerWrappers(reducerWrappers: ReducerWrapper<any>[]): this;
addHandler(type: string, handler: Handler<S>): this;
getNavigationProps(func: Handler<S>): string[];
lambdaFuncToInitialPropInfo(func: Handler<S>): PropInfo;
addPropChangedHandler(type: string, mappingFunc?: ((state: S, payload: any) => any), payloadFunc?: Handler<S>): this;
getReducer(otherReducers?: ExtendedReducersMapObject): (state: S, action: AnyAction) => S;
static importFrom<S>(anotherReducer: Reducer<S>, initialState: S): ReducerWrapper<S>;
}
declare class ActionCollections {
generator: ActionGeneratorDict;
name: string;
constructor(name: string, actions: AnyActionDictionary);
setExecutor(dispatch: Dispatch<AnyAction>): AnyActionDictionary;
}
declare let dispatchAction: <S>(dispatchFunc: Dispatch<AnyAction>, type: string, payload?: any) => AnyAction;
export { uselessReducer as uselessReducer, combineReducerWrapper as combineReducerWrapper, StoreWrapper as StoreWrapper, ActionCollections as ActionCollections, ReducerWrapper as ReducerWrapper, dispatchAction as dispatchAction };