-
Notifications
You must be signed in to change notification settings - Fork 0
NestJS : How to emit an event
Mathieu edited this page May 24, 2022
·
7 revisions
Before to trigger an event, we suggest you to read this article : NestJs Event - Event Emitter package.
EventEmitter2 is used to emit and listening an event. It's possible to see code production samples inside the products.service.ts.
For example, after the creation of a product, line bellow is used:
this.eventEmitter.emit('product.created', product);This emit product.created, it means than a product has been created.
https://github.com/MathieuBurnat/api-client-bc/blob/master/src/events/listeners/product.listener.ts