Skip to content

Commit b79bc83

Browse files
committed
Extended readme.
1 parent e7a80de commit b79bc83

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

packages/outbox-core/README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,29 @@ const job = new OutboxPeriodicJob(
3535

3636
Job will take care of processing outbox entries emitted by:
3737
```typescript
38-
const emitter = new OutboxEventEmitter(
38+
import {
39+
type CommonEventDefinition,
40+
enrichMessageSchemaWithBase,
41+
} from '@message-queue-toolkit/schemas'
42+
43+
const MyEvents = {
44+
created: {
45+
...enrichMessageSchemaWithBase(
46+
'entity.created',
47+
z.object({
48+
message: z.string(),
49+
}),
50+
),
51+
},
52+
} as const satisfies Record<string, CommonEventDefinition>
53+
54+
type MySupportedEvents = (typeof TestEvents)[keyof typeof TestEvents][]
55+
56+
const emitter = new OutboxEventEmitter<MySupportedEvents>(
3957
//Same instance of outbox storage that is used by OutboxPeriodicJob
4058
outboxStorage
4159
)
60+
61+
//It pushes the entry to the storage, later will be picked up by the OutboxPeriodicJob
62+
await emitter.emit(/* args */)
4263
```

0 commit comments

Comments
 (0)