docs: added workflow hooks docs + changed workflow response (#8364)

* docs: added workflow hooks docs + changed workflow response

* Update page.mdx
This commit is contained in:
Shahed Nasser
2024-07-31 17:01:33 +03:00
committed by GitHub
parent 27837b8833
commit 6f973d9f2b
29 changed files with 321 additions and 167 deletions
@@ -19,14 +19,15 @@ Since if-conditions aren't allowed in the workflow constructor function, use the
For example:
export const highlights = [
["15", "input", "The data to pass as a parameter to the function in the second parameter"],
["17", "return", "The function must return a boolean value indicating whether\nthe callback function passed to `then` should be executed."],
["19", "() => {", "The function to execute if `when`'s second parameter returns a `true` value."]
["16", "input", "The data to pass as a parameter to the function in the second parameter"],
["18", "return", "The function must return a boolean value indicating whether\nthe callback function passed to `then` should be executed."],
["20", "() => {", "The function to execute if `when`'s second parameter returns a `true` value."]
]
```ts highlights={highlights}
import {
createWorkflow,
WorkflowResponse,
when,
} from "@medusajs/workflows-sdk"
// step imports...
@@ -49,7 +50,11 @@ const workflow = createWorkflow(
})
// executed without condition
return anotherStep(result)
const anotherStepResult = anotherStep(result)
return new WorkflowResponse(
anotherStepResult
)
}
)
```