EventDefinition defines the event handling logic in a flow, used to respond to specific event triggers. Events are an important mechanism in the FlowEngine for triggering flow execution.
EventDefinition is actually an alias for ActionDefinition, so it has the same properties and methods.
Type: string
Required: Yes
Description: The unique identifier for the event.
Used to reference the event in a flow via the on property.
Example:
Type: string
Required: No
Description: The display title for the event.
Used for UI display and debugging.
Example:
Type: (ctx: TCtx, params: any) => Promise<any> | any
Required: Yes
Description: The handler function for the event.
The core logic of the event, which receives the context and parameters, and returns the processing result.
Example:
Type: Record<string, any> | ((ctx: TCtx) => Record<string, any> | Promise<Record<string, any>>)
Required: No
Description: The default parameters for the event.
Populates parameters with default values when the event is triggered.
Example:
Type: Record<string, ISchema> | ((ctx: TCtx) => Record<string, ISchema> | Promise<Record<string, ISchema>>)
Required: No
Description: The UI configuration schema for the event.
Defines the display method and form configuration for the event in the UI.
Example:
Type: (ctx: FlowSettingsContext<TModel>, params: any, previousParams: any) => void | Promise<void>
Required: No
Description: Hook function executed before saving parameters.
Executed before event parameters are saved, can be used for parameter validation or transformation.
Example:
Type: (ctx: FlowSettingsContext<TModel>, params: any, previousParams: any) => void | Promise<void>
Required: No
Description: Hook function executed after saving parameters.
Executed after event parameters are saved, can be used to trigger other actions.
Example:
Type: StepUIMode | ((ctx: FlowRuntimeContext<TModel>) => StepUIMode | Promise<StepUIMode>)
Required: No
Description: The UI display mode for the event.
Controls how the event is displayed in the UI.
Supported modes:
'dialog' - Dialog mode'drawer' - Drawer mode'embed' - Embed modeExample:
The FlowEngine has the following common event types built-in:
'click' - Click event'submit' - Submit event'reset' - Reset event'remove' - Remove event'openView' - Open view event'dropdownOpen' - Dropdown open event'popupScroll' - Popup scroll event'search' - Search event'customRequest' - Custom request event'collapseToggle' - Collapse toggle event