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>(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:350
类型工厂:锁定全局路径与元数据类型,生成定制化的实例化函数。
Type Parameters
P
P extends MeshPath
当前项目定义的路径字面量类型 (MeshPath)
S
S extends any[] | Record<string, any> = any
初始 Schema 的结构定义
NM
NM extends Record<string, any> = any
节点元数据 (Node Metadata) 的类型定义
Returns
<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>(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>
Description
这是一个高阶函数(Currying),旨在解决泛型冗余。通过预先注入 MeshPath (P) 和 MetaType (NM), 你会得到一个“专属”的实例化工具,从而避免在业务代码中反复书写冗长的泛型尖括号。 工作流:
- 在项目初始化/配置文件中定义:
const defineMesh = useMeshFlowDefiner<MyPaths, MyMeta>(); - 在业务逻辑中实例化:
const engine = defineMesh('app-engine', schema, { ... });