Skip to content

Commit e899013

Browse files
authored
chore: fix payloads of events in TSDocs + description of emitEventStep (medusajs#14132)
1 parent c3cebdf commit e899013

File tree

2 files changed

+102
-82
lines changed

2 files changed

+102
-82
lines changed

packages/core/core-flows/src/common/steps/emit-event.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type Input = {
3030
* The data payload that the subscriber receives in the `data` property
3131
* of its first parameter. Use this property to pass data relevant for the
3232
* subscriber, such as the ID of a created record.
33+
*
34+
* If you pass an array of objects, the event will be emitted once per each object in the array.
3335
*/
3436
data:
3537
| ((context: StepExecutionContext) => Promise<Record<any, any>>)
@@ -46,12 +48,30 @@ export const emitEventStepId = "emit-event-step"
4648
* If the workflow fails, it won't emit the event at all.
4749
*
4850
* @example
51+
* To emit a single event with a data payload:
52+
*
53+
* ```ts
4954
* emitEventStep({
5055
* eventName: "custom.created",
5156
* data: {
5257
* id: "123"
5358
* }
5459
* })
60+
* ```
61+
*
62+
* To emit an event multiple times with different data payloads, pass an array of objects to the `data` property:
63+
*
64+
* ```ts
65+
* emitEventStep({
66+
* eventName: "custom.created",
67+
* data: [
68+
* // emit will be emitted three times, once per each object in the array
69+
* { id: "123" },
70+
* { id: "456" },
71+
* { id: "789" }
72+
* ]
73+
* })
74+
* ```
5575
*/
5676
export const emitEventStep = createStep(
5777
emitEventStepId,

0 commit comments

Comments
 (0)