Skip to content

Commit 09095ad

Browse files
Merge pull request #2888 from koreanddinghwan/docs/event-listener-options
docs(events): add events listener options
2 parents bcfeae0 + 17b4c92 commit 09095ad

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

content/techniques/events.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,32 @@ handleOrderCreatedEvent(payload: OrderCreatedEvent) {
8585

8686
> warning **Warning** Event subscribers cannot be request-scoped.
8787
88-
The first argument can be a `string` or `symbol` for a simple event emitter and a `string | symbol | Array<string | symbol>` in a case of a wildcard emitter. The second argument (optional) is a listener options object ([read more](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean)).
88+
The first argument can be a `string` or `symbol` for a simple event emitter and a `string | symbol | Array<string | symbol>` in a case of a wildcard emitter.
89+
90+
The second argument (optional) is a listener options object as follows:
91+
92+
93+
```typescript
94+
export type OnEventOptions = OnOptions & {
95+
/**
96+
* If "true", prepends (instead of append) the given listener to the array of listeners.
97+
*
98+
* @see https://github.com/EventEmitter2/EventEmitter2#emitterprependlistenerevent-listener-options
99+
*
100+
* @default false
101+
*/
102+
prependListener?: boolean;
103+
104+
/**
105+
* If "true", the onEvent callback will not throw an error while handling the event. Otherwise, if "false" it will throw an error.
106+
*
107+
* @default true
108+
*/
109+
suppressErrors?: boolean;
110+
};
111+
```
112+
113+
> info **Hint** Read more about the `OnOptions` options object from [`eventemitter2`](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean).
89114
90115
```typescript
91116
@OnEvent('order.created', { async: true })

0 commit comments

Comments
 (0)