Skip to main content
Skip to main content
You're viewing the documentation for v1, which isn't the latest Medusa version.Latest documentation

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​

import {
createWorkflow,
parallelize
} from "@medusajs/workflows-sdk"
import {
createProductStep,
getProductStep,
createPricesStep,
attachProductToSalesChannelStep
} from "./steps"

interface WorkflowInput {
title: string
}

const myWorkflow = createWorkflow<
WorkflowInput,
Product
>("my-workflow", (input) => {
const product = createProductStep(input)

const [prices, productSalesChannel] = parallelize(
createPricesStep(product),
attachProductToSalesChannelStep(product)
)

const id = product.id
return getProductStep(product.id)
}
)

Type Parameters​

TResultWorkflowData[]Required
The type of the expected result.

Parameters​

stepsTResultRequired

Returns​

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