(
setAppState: (updater: (prev: AppState) => AppState) => void,
sessionId: string,
event: HookEvent,
matcher: string,
callback: FunctionHookCallback,
errorMessage: string,
options?: {
timeout?: number
id?: string
},
)
| 91 | * @returns The hook ID (for removal) |
| 92 | */ |
| 93 | export function addFunctionHook( |
| 94 | setAppState: (updater: (prev: AppState) => AppState) => void, |
| 95 | sessionId: string, |
| 96 | event: HookEvent, |
| 97 | matcher: string, |
| 98 | callback: FunctionHookCallback, |
| 99 | errorMessage: string, |
| 100 | options?: { |
| 101 | timeout?: number |
| 102 | id?: string |
| 103 | }, |
| 104 | ): string { |
| 105 | const id = options?.id || `function-hook-${Date.now()}-${Math.random()}` |
| 106 | const hook: FunctionHook = { |
| 107 | type: 'function', |
| 108 | id, |
| 109 | timeout: options?.timeout || 5000, |
| 110 | callback, |
| 111 | errorMessage, |
| 112 | } |
| 113 | addHookToSession(setAppState, sessionId, event, matcher, hook) |
| 114 | return id |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Remove a function hook by ID from the session. |
no test coverage detected