Files
vercel__workflow/packages/swc-plugin-workflow/examples/use-step-example.ts
Gal Schlezinger 4ca9a3edbd Introducing Workflow DevKit
build durable, resilient, and observable workflows.

Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
Co-authored-by: Adrian <me@adriandlam.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Vercel Release Bot <88769842+vercel-release-bot@users.noreply.github.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
Co-authored-by: Manuel Muñoz Solera <mamuso@mamuso.net>
Co-authored-by: Garrett <garrett.tolbert@vercel.com>
Co-authored-by: Lars Grammel <lars.grammel@gmail.com>
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
Co-authored-by: Tom Dale <tom@tomdale.net>
Co-authored-by: Vishal Yathish <135551666+visyat@users.noreply.github.com>
Co-authored-by: josh <144584931+dancer@users.noreply.github.com>
2025-10-23 12:07:52 +03:00

32 lines
776 B
TypeScript

// NOTE: These examples should become fixture testing
// Example 1: Function with "use step" directive
async function add(a: number, b: number) {
'use step';
return a + b;
}
// Example 2: Arrow function with "use step"
export const multiply = async (x: number, y: number) => {
'use step';
return x * y;
};
// Example 3: File-level directive
// In another file:
// "use step";
//
// export async function processOrder(orderId: string) {
// // Process the order
// return { status: 'processed', orderId };
// }
//
// export async function sendNotification(userId: string, message: string) {
// // Send notification
// return { sent: true };
// }
// Usage
add(1, 2).then((result) => console.log(result));
multiply(3, 4).then((result) => console.log(result));