@farris/devkit-vue
Version:
205 lines (204 loc) • 4.69 kB
TypeScript
import { EffectManager, EventBus, Injector } from '../common/index';
import { Devkit } from '../devkit';
import { Entity, EntityState, EntityStore, UIState, UIStore, FormState, FormStore, FormArrayState, FormArrayStore, StateMachineState, StateMachine, StateChange } from '../store/index';
import { Repository } from '../repository/index';
import { ViewModel, ViewModelState } from '../viewmodel/index';
import { ModuleConfig, ModuleConfigManager } from './configs/index';
import { Context } from '../context';
/**
* 模块注入Token
*/
declare const MODULE_INJECTION_TOKEN: unique symbol;
/**
* 模块定义
*/
declare class Module {
/**
* 模块ID
*/
private id;
/**
* 注入器
*/
private injector;
/**
* 配置管理
*/
private configManager;
/**
* 实体仓库集合
*/
private entityStores;
/**
* UI仓库集合
*/
private uiStores;
/**
* 表单仓库集合
*/
private formStores;
/**
* 表单数组仓库集合
*/
private formArrayStores;
/**
* 状态机集合
*/
private stateMachines;
/**
* 远程实体仓库集合
*/
private repositories;
/**
* 视图模型集合
*/
private viewModels;
/**
* 上下文
*/
private context;
/**
* 事件总线
*/
private eventBus;
/**
*
*/
private locale;
/**
* 副作用管理
*/
effectManager: EffectManager<StateChange<any>>;
/**
* 构造函数
*/
constructor(injector: Injector);
/**
* 初始化
*/
init(config: ModuleConfig): void;
/**
* 获取注入器
*/
getInjector(): Injector;
updateInjector(injector: any): void;
/**
* 获取框架框架实例
*/
getDevkit(): Devkit;
/**
* 获取配置管理器
*/
getConfigManager(): ModuleConfigManager;
/**
* 获取视图模型
*/
getViewModel(id: string): ViewModel<ViewModelState> | null;
/**
* 获取全部视图模型
*/
getViewModels(): ViewModel<ViewModelState>[];
/**
* 获取当前module的根视图模型
* @returns
*/
getRootViewModel(): ViewModel<ViewModelState>;
/**
* 获取实体仓库
*/
getEntityStore(id: string): EntityStore<EntityState<Entity>> | null;
/**
* 获取全部实体仓库
*/
getEntityStores(): EntityStore<EntityState<Entity>>[];
/**
* 获取UI仓库
*/
getUIStore(id: string): UIStore<UIState> | null;
/**
* 获取全部UI仓库
*/
getUIStores(): UIStore<UIState>[];
/**
* 获取Form仓库
*/
getFormStore(id: string): FormStore<FormState> | null;
/**
* 获取全部Form仓库
*/
getFormStores(): FormStore<FormState>[];
/**
* 获取Form仓库
*/
getFormArrayStore(id: string): FormArrayStore<FormArrayState> | null;
/**
* 获取全部Form仓库
*/
getFormArrayStores(): FormArrayStore<FormArrayState>[];
/**
* 获取状态机
*/
getStateMachine(id: string): StateMachine<StateMachineState> | null;
/**
* 获取全部状态机
*/
getStateMachines(): StateMachine<StateMachineState>[];
/**
* 获取远程实体仓库
*/
getRepository(id: string): Repository<Entity> | null;
/**
* 注册视图模型
*/
registerViewModel(id: string, viewModel: ViewModel<ViewModelState>): void;
/**
* 构造实体仓库
*/
createEntityStore(id: string): EntityStore<EntityState<Entity>>;
/**
* 创建UI仓库
*/
createUIStore(id: string): UIStore<UIState>;
/**
* 创建表单仓库
*/
createFormStore(id: string): FormStore<FormState>;
/**
* 创建表单数组仓库
*/
createFormArrayStore(id: string): FormArrayStore<FormArrayState>;
/**
* 创建状态机
*/
createStateMachine(id: string): StateMachine<StateMachineState>;
/**
* 创建模块
*/
createRepository(id: string): Repository<Entity>;
/**
* module上下文
* @returns
*/
getContext(): Context;
getId(): string;
getEventBus(): EventBus;
/**
* 当前语言
* @returns
*/
getLocale(): string;
getDevkitType(): string;
/**
* 监听变更
*/
watchChange(changeEffectFunc: (change: StateChange<any>) => void): Function;
/**
* 触发变更
*/
triggerChange(change: any): void;
}
/**
* 使用模块
*/
declare function useModule(id: string): Module;
export { MODULE_INJECTION_TOKEN, Module, useModule };