I don't know how to handle the following emitter:
async create(createJobDto: CreateJobDto) {
this.eventEmitter.emit(
['job','create'],
createJobDto,
);
}
async update(createJobDto: CreateJobDto) {
this.eventEmitter.emit(
['job','update'],
createJobDto,
);
}
Listener:
@OnEvent('job.**')
handleJobEvent(data: CreateJobDto) {
console.log(data);
});
The NestJS and the EventEmitter2 docs mention that I can use an array as a wildcard, but how can I distinguish between "create" and "update" in the listener? All that I seem to get in data is the job object.
P.S. I am correctly including the EventEmitterModule in my imports:
EventEmitterModule.forRoot({
wildcard: true
}),
from Handle EventEmitterModule wildcards - NestJS
No comments:
Post a Comment