The NocoBase FlowEngine's context system is divided into three layers, each corresponding to a different scope. Proper use can achieve flexible sharing and isolation of services, configurations, and data, improving business maintainability and scalability.
mode: 'runtime' | 'settings', corresponding to runtime mode and settings mode respectively.All FlowEngineContext (Global Context), FlowModelContext (Model Context), FlowRuntimeContext (Flow Runtime Context), etc., are subclasses or instances of FlowContext.
FlowModelContext can access the properties and methods of FlowEngineContext through a delegate mechanism, enabling the sharing of global capabilities.FlowModelContext can access the parent model's context (synchronous relationship) through a delegate mechanism, supporting same-name overrides.FlowRuntimeContext always accesses its corresponding FlowModelContext through a delegate mechanism, but it does not propagate changes upwards.FlowRuntimeContext supports two modes, distinguished by the mode parameter:
mode: 'runtime' (Runtime mode): Used during the actual execution phase of the flow. Properties and methods return real data. For example:
mode: 'settings' (Settings mode): Used during the flow design and configuration phase. Property access returns a variable template string, facilitating expression and variable selection. For example:
This dual-mode design ensures data availability at runtime and facilitates variable referencing and expression generation during configuration, enhancing the flexibility and usability of the FlowEngine.