Recall & Review
beginner
What is event handling in NestJS?
Event handling in NestJS is a way to listen for and respond to events within the application, allowing different parts of the app to communicate without tight coupling.
Click to reveal answer
beginner
Which decorator is used to listen to events in NestJS?
The @OnEvent() decorator is used to mark a method as an event listener for a specific event name.
Click to reveal answer
beginner
How do you emit an event in NestJS?
You use the EventEmitter2 service's emit() method, passing the event name and optional payload to notify listeners.
Click to reveal answer
intermediate
Why use event handling in NestJS instead of direct method calls?
Event handling decouples components, making the app easier to maintain and extend by allowing parts to react to events without knowing who triggered them.
Click to reveal answer
beginner
What must you do to enable event handling in a NestJS application?
You must import and provide the EventEmitterModule in your module to use event handling features.Click to reveal answer
Which NestJS module provides event handling capabilities?
✗ Incorrect
EventEmitterModule is the official NestJS module that enables event handling.
What decorator do you use to listen for an event named 'user.created'?
✗ Incorrect
The correct decorator to listen for events is @OnEvent with the event name as argument.
How do you send data with an event in NestJS?
✗ Incorrect
You pass the data as the second argument to the emit() method.
What is a benefit of using event handling in NestJS?
✗ Incorrect
Event handling decouples components, improving maintainability.
Which service do you inject to emit events in NestJS?
✗ Incorrect
EventEmitter2 is the service used to emit events.
Explain how to set up and use event handling in a NestJS application.
Think about module setup, sending, and receiving events.
You got /4 concepts.
Describe the advantages of using event handling in NestJS compared to direct method calls.
Consider how event handling affects app structure and flexibility.
You got /4 concepts.