UNPKG

@chief-editor/flow

Version:

Old核心数据流

42 lines (41 loc) 1.84 kB
import { IDatasourceConfig } from '@chief-editor/base'; import { NestWatcher } from '@co-hooks/nest-watcher'; import { FunctionAny } from '@co-hooks/util'; import { Emitter } from '@co-hooks/emitter'; import { DatasourceLoader, FlowDatasource, IFlowBrickConfigGlobal } from '../types'; import { FlowModel, IModelOptions } from './FlowModel'; import { FlowScheduler } from './FlowScheduler'; export interface IContextOptions { context?: FlowContextInfo; hooks?: Record<string, FunctionAny>; loaders?: Record<string, DatasourceLoader>; brickConfigs?: Record<string, IFlowBrickConfigGlobal>; } export interface IContextEvents { 'context-change': [string[]]; } export declare type FlowContextInfo = Record<string, unknown>; export declare class FlowContext extends Emitter<IContextEvents> { private readonly context; private readonly hooks; private readonly brickConfigs; private readonly modelMap; private readonly watcher; private readonly loaders; constructor({ context, hooks, loaders, brickConfigs }: IContextOptions); setContext(key: string, value?: unknown): void; setContext(context: FlowContextInfo): void; getContext(key: string, isDirect?: boolean): unknown; getContext(isDirect?: boolean): FlowContextInfo; getHook(key: string): FunctionAny | null; getHooks(): { [key: string]: FunctionAny; }; getLoader<V, DS, DP, CG, ST>(config: IDatasourceConfig<V, DS>, scheduler: FlowScheduler<V, DS, DP, CG, ST>): FlowDatasource<V, DS, DP, CG, ST>; getBrickConfig(type: string): IFlowBrickConfigGlobal; getBrickConfigs(): Record<string, IFlowBrickConfigGlobal>; getWatcher(): NestWatcher; createModel(opts: string | Omit<IModelOptions, 'context'>): FlowModel; removeModel(name: string): void; getModel(name: string): FlowModel; }