parallelize - Workflows API Reference
This documentation provides a reference to the parallelize
. It belongs to the @medusajs/workflows-sdk
package.
This function is used to run multiple steps in parallel. The result of each step will be returned as part of the result array.
Example#
1import {2 createWorkflow,3 parallelize4} from "@medusajs/workflows-sdk"5import {6 createProductStep,7 getProductStep,8 createPricesStep,9 attachProductToSalesChannelStep10} from "./steps"11 12interface WorkflowInput {13 title: string14}15 16const myWorkflow = createWorkflow<17 WorkflowInput,18 Product19>("my-workflow", (input) => {20 const product = createProductStep(input)21 22 const [prices, productSalesChannel] = parallelize(23 createPricesStep(product),24 attachProductToSalesChannelStep(product)25 )26 27 const id = product.id28 return getProductStep(product.id)29 }30)
Type Parameters#
The type of the expected result.
Parameters#
steps
TResultReturns#
TResult
TResultThe step results. The results are ordered in the array by the order they're passed in the function's parameter.
Was this page helpful?