import { ProviderSourceConfig, runTimeType } from '../../types'; import { containerActionCreators } from '../Container/action'; import { ContainerProps } from '../Container/Container'; import { RunTimeContextCollection } from '../context'; import { SyncAdaptor } from './adaptors/sync'; import { AsyncAdaptor } from './adaptors/async'; import { SocketAdaptor } from './adaptors/socket'; export * from './adaptors/async'; export * from './adaptors/sync'; export interface ProviderActions { /** * 异步加载中 */ asyncLoadDataProgress: typeof containerActionCreators.asyncLoadDataProgress; /** * 异步加载成功 */ asyncLoadDataSuccess: typeof containerActionCreators.asyncLoadDataSuccess; /** * 异步加载失败 */ asyncLoadDataFail: typeof containerActionCreators.asyncLoadDataFail; } /** * DataProvider 是一个数据源控制器 * 它通过为Container组件提供一个单一, 简单的API调用. 来对各种各样的数据获取操作进行封装 * 它支持控制同步的数据和异步的数据操作. 获取到目标数据之后, * DataProvider会触发action来写入数据到redux store * * 流程图可参考 * src/doc/graphic/dataFlow.png * * 同步的操作会触发一个action, 并进行同步写入 * 异步的操作会有3个运行状态: * * 1. before(异步运行前) * 2. progress(异步运行中) * 3.1 success(异步运行成功) * 3.2 fail(异步运行失败) */ export declare class DataProvider { static providerInstance: { [mode: string]: { type: 'sync'; instance: SyncAdaptor; } | { type: 'async'; instance: AsyncAdaptor; } | { type: 'socket'; instance: SocketAdaptor; }; }; providerCache: { [namespace: string]: any; }; isUnmount: boolean; dependencies: { [namespace: string]: { dep: string[]; beDep: string[]; }; }; buildInProvider: { [namespace: string]: ProviderSourceConfig; }; taskQueue: string[][]; static registerSyncProvider(mode: string, adaptor: SyncAdaptor): void; static registerAsyncProvider(mode: string, adaptor: AsyncAdaptor): void; static registerSocketProvider(mode: string, adaptor: SocketAdaptor): void; static getProvider(mode: string): { type: "sync"; instance: SyncAdaptor; } | { type: "async"; instance: AsyncAdaptor; } | { type: "socket"; instance: SocketAdaptor; } | null; constructor(providerList: ProviderSourceConfig[]); depose(): void; buildDependencies(providerList: ProviderSourceConfig[]): void; computeRequestGroup(providerList: ProviderSourceConfig[]): void; getRequestTaskQueue(key: string, deps: string[], road: string, paths: { [key: string]: boolean; }, roads: string[]): void; shouldRequestData(provider: ProviderSourceConfig, runTime: runTimeType, model: string, props: ContainerProps, context: RunTimeContextCollection): false | ProviderSourceConfig; execProvider(config: any, provider: ProviderSourceConfig, runTime: runTimeType, actions: ProviderActions, model: string): Promise; private handleAdaptorResult; private execSyncAdaptor; private execAsyncAdaptor; private applyRetMapping; private applyResponseRewrite; private handleError; getRunTime(model: string, props: ContainerProps, context: RunTimeContextCollection): import("../../types").RunTimeType; requestForData(model: string, providerConfig: ProviderSourceConfig[], actions: ProviderActions, props: ContainerProps, context: RunTimeContextCollection): Promise<{} | null>; }