Skip to content

MeshFlow Core API


MeshFlow Core API / useMeshFlowDefiner

Function: useMeshFlowDefiner()

useMeshFlowDefiner<P, S, NM>(): <T, M>(id, schema, options) => Engine<{ batchRenderExport: { init: any; }; destroyPlugin: () => void; dispose: () => void; formExports: { }; GetAllDependency: () => number[][]; GetDependencyOrder: () => number[][]; GetGroupByPath: (path) => MeshFlowGroupNode<MeshPath>; GetValue: (path, key) => any; hasRenderGate: () => boolean; historyExports: MeshFlowHistory; notifyAll: () => Promise<void>; onError: (cb) => Unsubscribe; onStart: (cb) => () => void; onSuccess: (cb) => () => void; scheduler: MeshScheduler<T, P, any, NM>; SetRule: <K, TKeys>(outDegreePath, inDegreePath, key, options) => void; SetRules: <TKeys, K>(outDegreePaths, inDegreePath, key, options) => void; SetStrategy: (path, key, strategy) => void; SettleTasks: (array) => void; SetValue: (path, key, value) => void; SetValues: (updates) => void; SilentSet: (path, key, value) => boolean; StageValue: (path, key, value) => void; useEntangle: <State>(config) => void; usePlugin: (plugin) => () => void; validatorExports: { SetValidators?: (path, options) => void; }; }, M, P>

Defined in: engine/useEngineManager.ts:396

[BOT] 类型工厂(Currying)——预先锁定泛型,生成专属实例化函数

useMeshFlow 的差异

useMeshFlowuseMeshFlowDefiner
泛型位置每次调用都写工厂定义时写一次
路径推导从 Schema 推导手动锁定
适用场景单页面/简单项目大型项目、多次实例化

工作流:

  1. 配置文件中定义: const mesh = useMeshFlowDefiner<MyPaths, MyMeta>();
  2. 业务中实例化: const engine = mesh('app-engine', schema, { ... });

Type Parameters

P

P extends MeshPath

— 预锁定的路径字面量类型

S

S extends any[] | Record<string, any> = any

— Schema 结构类型

NM

NM extends Record<string, any> = any

— 预锁定的 MetaType

Returns

返回一个接收 (id, schema, options) 的实例化函数

<T, M>(id, schema, options) => Engine<{ batchRenderExport: { init: any; }; destroyPlugin: () => void; dispose: () => void; formExports: { }; GetAllDependency: () => number[][]; GetDependencyOrder: () => number[][]; GetGroupByPath: (path) => MeshFlowGroupNode<MeshPath>; GetValue: (path, key) => any; hasRenderGate: () => boolean; historyExports: MeshFlowHistory; notifyAll: () => Promise<void>; onError: (cb) => Unsubscribe; onStart: (cb) => () => void; onSuccess: (cb) => () => void; scheduler: MeshScheduler<T, P, any, NM>; SetRule: <K, TKeys>(outDegreePath, inDegreePath, key, options) => void; SetRules: <TKeys, K>(outDegreePaths, inDegreePath, key, options) => void; SetStrategy: (path, key, strategy) => void; SettleTasks: (array) => void; SetValue: (path, key, value) => void; SetValues: (updates) => void; SilentSet: (path, key, value) => boolean; StageValue: (path, key, value) => void; useEntangle: <State>(config) => void; usePlugin: (plugin) => () => void; validatorExports: { SetValidators?: (path, options) => void; }; }, M, P>

See

useMeshFlow 直接创建引擎

⧩ MeshFlow — 确定性拓扑编排引擎