/// import { Reducer, Action, AnyAction, MiddlewareAPI, StoreEnhancer, Store } from 'redux'; interface Dispatch { (action: T): Promise | T; } interface ActionFunc { (api: MiddlewareAPI): void; } interface ReducerEnhancer { (reducer: Reducer): void; } export declare type ReducersMapObject = { [K in keyof S]: Reducer; }; interface Hooks { onError?: (e: Error, dispatch: Dispatch) => void; onAction?: ActionFunc | ActionFunc[]; onStateChange?: () => void; onReducer?: ReducerEnhancer; onEffect?: () => void; onHmr?: () => void; extraReducers?: ReducersMapObject; extraEnhancers?: StoreEnhancer[]; } interface EffectsCommandMap { put: (action: A) => any; call: Function; select: Function; take: Function; cancel: Function; [key: string]: any; } declare type Effect = (action: AnyAction, effects: EffectsCommandMap) => void; declare type EffectType = 'takeEvery' | 'takeLatest' | 'watcher' | 'throttle'; declare type EffectWithType = [Effect, { type: EffectType; }]; declare type Subscription = (api: SubscriptionAPI, done: Function) => void; declare type ReducersMapObjectWithEnhancer = [ReducersMapObject, ReducerEnhancer]; interface EffectsMapObject { [key: string]: Effect | EffectWithType; } interface SubscriptionAPI { history: any; dispatch: Dispatch; } interface SubscriptionsMapObject { [key: string]: Subscription; } export interface Model { namespace: string; state?: any; reducers?: ReducersMapObject | ReducersMapObjectWithEnhancer; effects?: EffectsMapObject; subscriptions?: SubscriptionsMapObject; } interface RouterAPI { history: any; app: DvaInstance; } interface Router { (api?: RouterAPI): JSX.Element | Record; } declare type HandleActions = (handles: any, defaultState: Pick) => (state: any, action: AnyAction) => (prev: any, curr: any) => void; interface Plugin { _handleActions: HandleActions; hooks: Hooks & { _handleActions: HandleActions; }; use: (plugin: Hooks) => void; apply: (key: string, defaultHandler: Function) => (...args: any[]) => void; get: (key: keyof Hooks | '_handleActions') => any; } export interface DvaInstance { _models: Array; _store: Store; _plugin: Plugin; use: (hooks: Hooks) => void; model: (model: Model) => void; unmodel: (namespace: string) => void; router: (router: Router) => void; start: (selector?: HTMLElement | JSX.Element) => any; [key: string]: any; } export {};