MeshFlow Core API / useMeshFlowDefiner
Function: useMeshFlowDefiner()
useMeshFlowDefiner<
P,S,NM>(): <T,M>(id,schema,options) =>Engine<{batchRenderExport: {init:any; };CancelTask: () =>void;destroyPlugin: () =>void;formExports: { };GetAllDependency: () =>number[][];GetDependencyOrder: () =>number[][];GetGroupByPath: (path) =>MeshFlowGroupNode<MeshPath>;GetValue: (path,key) =>any;hasRenderGate: () =>boolean;historyExports:Partial<MeshFlowHistory>;notifyAll: () =>Promise<void>;onError: (cb) =>Unsubscribe;onStart: (cb) => () =>void;onSuccess: (cb) => () =>void;scheduler: {batchNotify: (updates) =>void;CancelTask: () =>void;GetBucket: (bucketId) =>SchemaBucket<P>;GetGroupByPath: (path) =>MeshFlowGroupNode<MeshPath>;GetNodeByPath: (path) =>MeshFlowTaskNode<P,any,NM>;notify: (path) =>void;notifyAll: () =>Promise<void>;refresTarget: (uid) =>void;registerGroupNode: (groupMeta) =>MeshFlowGroupNode<P>;registerNode: (nodeMeta) =>MeshFlowTaskNode<P,any,NM>;SetBucket: (newBucket) =>number;stageValueFn: (uid,key,value) =>void;UidToNodeMap:MeshFlowTaskNode<P,any,NM>[];UITrigger:any;updateEntangleLevel: () =>void;useEntangle: (config) =>void; };SetRule: <K,TKeys>(outDegreePath,inDegreePath,key,options) =>void;SetRules: <TKeys>(outDegreePaths,inDegreePath,key,options) =>void;SetStrategy: (path,key,strategy) =>void;SetTrace: (myPath,onUpdate) =>object;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:345
类型工厂:锁定全局路径与元数据类型,生成定制化的实例化函数。
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; }; CancelTask: () => void; destroyPlugin: () => void; formExports: { }; GetAllDependency: () => number[][]; GetDependencyOrder: () => number[][]; GetGroupByPath: (path) => MeshFlowGroupNode<MeshPath>; GetValue: (path, key) => any; hasRenderGate: () => boolean; historyExports: Partial<MeshFlowHistory>; notifyAll: () => Promise<void>; onError: (cb) => Unsubscribe; onStart: (cb) => () => void; onSuccess: (cb) => () => void; scheduler: { batchNotify: (updates) => void; CancelTask: () => void; GetBucket: (bucketId) => SchemaBucket<P>; GetGroupByPath: (path) => MeshFlowGroupNode<MeshPath>; GetNodeByPath: (path) => MeshFlowTaskNode<P, any, NM>; notify: (path) => void; notifyAll: () => Promise<void>; refresTarget: (uid) => void; registerGroupNode: (groupMeta) => MeshFlowGroupNode<P>; registerNode: (nodeMeta) => MeshFlowTaskNode<P, any, NM>; SetBucket: (newBucket) => number; stageValueFn: (uid, key, value) => void; UidToNodeMap: MeshFlowTaskNode<P, any, NM>[]; UITrigger: any; updateEntangleLevel: () => void; useEntangle: (config) => void; }; SetRule: <K, TKeys>(outDegreePath, inDegreePath, key, options) => void; SetRules: <TKeys>(outDegreePaths, inDegreePath, key, options) => void; SetStrategy: (path, key, strategy) => void; SetTrace: (myPath, onUpdate) => object; 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, { ... });