Events — Techniques · NestJS

Decouple what happens after an adoption from the code that adopts: CatsService emits namespaced events with typed payloads, and an audit module that never imports it listens, with a wildcard for the whole namespace.

What you will learn

Read the theory for Events

All Techniques lessons

All NestJS courses

loading types…

What you'll learn

  • Register EventEmitterModule and emit namespaced events with class payloads from a service
  • Listen with @OnEvent on any provider, including a wildcard over a namespace
  • Explain what events buy over direct calls, and when a listener runs relative to the response