From 80f06acfd1219da33df7fe35acb3eee463005a5a Mon Sep 17 00:00:00 2001 From: myukang Date: Wed, 18 Oct 2023 22:26:40 +0900 Subject: [PATCH 1/4] docs(events): add events listner options --- content/techniques/events.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/content/techniques/events.md b/content/techniques/events.md index 60769a050e..f11387a55d 100644 --- a/content/techniques/events.md +++ b/content/techniques/events.md @@ -85,7 +85,30 @@ handleOrderCreatedEvent(payload: OrderCreatedEvent) { > warning **Warning** Event subscribers cannot be request-scoped. -The first argument can be a `string` or `symbol` for a simple event emitter and a `string | symbol | Array` 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)). +The first argument can be a `string` or `symbol` for a simple event emitter and a `string | symbol | Array` in a case of a wildcard emitter. + +The second argument (optional) is a listener options object as follows: + + +```typescript +export type OnEventOptions = OnOptions & { + /** + * If "true", prepends (instead of append) the given listener to the array of listeners. + * + * @see https://github.com/EventEmitter2/EventEmitter2#emitterprependlistenerevent-listener-options + * + * @default false + */ + prependListener?: boolean; + + /** + * If "true", the onEvent callback will not throw an error while handling the event. Otherwise, if "false" it will throw an error. + * + * @default true + */ + suppressErrors?: boolean; +}; +``` ```typescript @OnEvent('order.created', { async: true }) @@ -94,6 +117,9 @@ handleOrderCreatedEvent(payload: OrderCreatedEvent) { } ``` +> info **Hint** read more about ([listener options object](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean)). + + To use namespaces/wildcards, pass the `wildcard` option into the `EventEmitterModule#forRoot()` method. When namespaces/wildcards are enabled, events can either be strings (`foo.bar`) separated by a delimiter or arrays (`['foo', 'bar']`). The delimiter is also configurable as a configuration property (`delimiter`). With namespaces feature enabled, you can subscribe to events using a wildcard: ```typescript From ec846c74ded27bcf28cd563a5cf252298ccb5874 Mon Sep 17 00:00:00 2001 From: Myukang <76278794+koreanddinghwan@users.noreply.github.com> Date: Wed, 18 Oct 2023 23:13:28 +0900 Subject: [PATCH 2/4] Update content/techniques/events.md Co-authored-by: Micael Levi L. Cavalcante --- content/techniques/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/techniques/events.md b/content/techniques/events.md index f11387a55d..fc135d70e8 100644 --- a/content/techniques/events.md +++ b/content/techniques/events.md @@ -117,7 +117,7 @@ handleOrderCreatedEvent(payload: OrderCreatedEvent) { } ``` -> info **Hint** read more about ([listener options object](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean)). +> info **Hint** read more about the [`OnOptions` options object from `eventemitter2`](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean). To use namespaces/wildcards, pass the `wildcard` option into the `EventEmitterModule#forRoot()` method. When namespaces/wildcards are enabled, events can either be strings (`foo.bar`) separated by a delimiter or arrays (`['foo', 'bar']`). The delimiter is also configurable as a configuration property (`delimiter`). With namespaces feature enabled, you can subscribe to events using a wildcard: From f61b56cf144f18ed77f9893110b7b5b4460c5a84 Mon Sep 17 00:00:00 2001 From: Myukang <76278794+koreanddinghwan@users.noreply.github.com> Date: Wed, 18 Oct 2023 23:15:56 +0900 Subject: [PATCH 3/4] docs: change hint line --- content/techniques/events.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/content/techniques/events.md b/content/techniques/events.md index fc135d70e8..21ebed5011 100644 --- a/content/techniques/events.md +++ b/content/techniques/events.md @@ -110,6 +110,8 @@ export type OnEventOptions = OnOptions & { }; ``` +> info **Hint** Read more about the [`OnOptions` options object from `eventemitter2`](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean). + ```typescript @OnEvent('order.created', { async: true }) handleOrderCreatedEvent(payload: OrderCreatedEvent) { @@ -117,9 +119,6 @@ handleOrderCreatedEvent(payload: OrderCreatedEvent) { } ``` -> info **Hint** read more about the [`OnOptions` options object from `eventemitter2`](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean). - - To use namespaces/wildcards, pass the `wildcard` option into the `EventEmitterModule#forRoot()` method. When namespaces/wildcards are enabled, events can either be strings (`foo.bar`) separated by a delimiter or arrays (`['foo', 'bar']`). The delimiter is also configurable as a configuration property (`delimiter`). With namespaces feature enabled, you can subscribe to events using a wildcard: ```typescript From 17b4c9244579c7934fb2e3136df8345db2b428b3 Mon Sep 17 00:00:00 2001 From: Kamil Mysliwiec Date: Mon, 23 Oct 2023 09:54:24 +0200 Subject: [PATCH 4/4] Update content/techniques/events.md --- content/techniques/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/techniques/events.md b/content/techniques/events.md index 21ebed5011..d08dbca0e8 100644 --- a/content/techniques/events.md +++ b/content/techniques/events.md @@ -110,7 +110,7 @@ export type OnEventOptions = OnOptions & { }; ``` -> info **Hint** Read more about the [`OnOptions` options object from `eventemitter2`](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean). +> info **Hint** Read more about the `OnOptions` options object from [`eventemitter2`](https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectboolean). ```typescript @OnEvent('order.created', { async: true })