feature: share execution context with hook handlers (#8501)
This commit is contained in:
1 parent
f831deaf74
commit
9cd66bc842
2 files changed
+5
-2
No files matched your search
@@ -30,8 +30,9 @@ const workflow = createWorkflow(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
workflow.hooks.something((input) => {
|
workflow.hooks.something((input, context) => {
|
||||||
console.log("input>", input)
|
console.log("input>", input)
|
||||||
|
console.log("context>", context)
|
||||||
})
|
})
|
||||||
|
|
||||||
workflow.run().then((res) => {
|
workflow.run().then((res) => {
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ export type HookHandler = (...args: any[]) => void | Promise<void>
|
|||||||
type ConvertHooksToFunctions<THooks extends any[]> = {
|
type ConvertHooksToFunctions<THooks extends any[]> = {
|
||||||
[K in keyof THooks]: THooks[K] extends Hook<infer Name, infer Input>
|
[K in keyof THooks]: THooks[K] extends Hook<infer Name, infer Input>
|
||||||
? {
|
? {
|
||||||
[Fn in Name]: (callback: (input: Input) => any) => void
|
[Fn in Name]: (
|
||||||
|
callback: (input: Input, context: StepExecutionContext) => any
|
||||||
|
) => void
|
||||||
}
|
}
|
||||||
: never
|
: never
|
||||||
}[number]
|
}[number]
|
||||||
|
|||||||
Reference in new issue
Block a user