parallelize - Workflows API Reference

This documentation provides a reference to the parallelize . It belongs to the @medusajs/framework/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#

Code
1import {2  createWorkflow,3  parallelize,4  WorkflowResponse5} from "@medusajs/framework/workflows-sdk"6import {7  createProductStep,8  getProductStep,9  createPricesStep,10  attachProductToSalesChannelStep11} from "./steps"12
13interface WorkflowInput {14  title: string15}16
17const myWorkflow = createWorkflow(18  "my-workflow",19  (input: WorkflowInput) => {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 new WorkflowResponse(getProductStep(product.id))29 }30)

Type Parameters#

TResultWorkflowData[]Optional
The type of the expected result.

Parameters#

stepsTResult

Returns#

TResultTResult
The step results. The results are ordered in the array by the order they're passed in the function's parameter.
Was this page helpful?