[DX] Why use directives for steps?
#216
-
|
Hey, I’m curious of why would this: // Workflow function (orchestrates the steps)
export async function greetingWorkflow(name: string) {
"use workflow";
const message = await greet(name);
return { message };
}
// Step function (does the actual work)
async function greet(name: string) {
"use step”;
...
}Be preferred over a simple // Workflow function (orchestrates the steps)
export async function greetingWorkflow(name: string) {
"use workflow”;
- const message = await greet(name);
+ const message = await step(greet(name));
return { message };
}
// Step function (does the actual work)
async function greet(name: string) {
- "use step”;
...
}The former adds clutter to the function or forces you to create a wrapper on functions you can’t modify such as in external libraries. So I’m wondering, what is the adventage of directives? Don’t mean to nitpick I’m just curious. Looking forward to using this library, thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
There's a full post here on our docs about directives including a section on "use step" - https://useworkflow.dev/docs/how-it-works/understanding-directives#how-directives-solve-these-problems Please lemme know if there's anything missing on that doc once you've read through it |
Beta Was this translation helpful? Give feedback.
There's a full post here on our docs about directives including a section on "use step" - https://useworkflow.dev/docs/how-it-works/understanding-directives#how-directives-solve-these-problems
Please lemme know if there's anything missing on that doc once you've read through it