ChainGraph API Documentation / @badaitech/chaingraph-types / createExecutionEventHandler
Function: createExecutionEventHandler()
createExecutionEventHandler(
handlers,options): (event) =>Promise<void>
Defined in: packages/chaingraph-types/src/flow/execution-handlers.ts:109
Creates a reusable execution event handler with predefined handlers and options
Parameters
handlers
Map of event handlers
options
HandleExecutionEventOptions = {}
Additional options for event handling
Returns
A function that can handle execution events
(
event):Promise<void>
Parameters
event
Returns
Promise<void>
Example
typescript
const handleEvent = createExecutionEventHandler({
[ExecutionEventEnum.FLOW_STARTED]: (data, context) => {
console.log('Flow started:', data.flow.id)
}
}, {
onError: (error) => console.error('Handler error:', error)
})
// Use the handler
await handleEvent(event)