Skip to content

ChainGraph API Documentation / @badaitech/chaingraph-types / handleExecutionEvent

Function: handleExecutionEvent()

handleExecutionEvent<T>(event, handlers, options): Promise<void>

Defined in: packages/chaingraph-types/src/flow/execution-handlers.ts:67

Processes an execution event using provided handlers

Type Parameters

T

T extends ExecutionEventEnum

Parameters

event

ExecutionEventImpl<T>

The execution event to process

handlers

ExecutionEventHandlerMap

Map of event handlers

options

HandleExecutionEventOptions = {}

Additional options for event handling

Returns

Promise<void>

Example

typescript
const handlers: ExecutionEventHandlerMap = {
  [ExecutionEventEnum.NODE_STARTED]: (data, context) => {
    console.log('Node started:', data.node.id)
  },
  [ExecutionEventEnum.NODE_COMPLETED]: (data, context) => {
    console.log('Node completed:', data.node.id, 'in', data.executionTime, 'ms')
  }
}

// Handle single event
await handleExecutionEvent(event, handlers)

Licensed under BUSL-1.1