I wanted to use custom publisher for commands, events and queries, but it doesn't work. If I connect my own publisher in onModuleInit method this.command$.publisher = this.commandPublisher; and then in a controller call this.commandBus.execute(...), my publisher won't be called, because this publisher is never called in the command bus class. To make it work, I have to manually call this.commandBus.publisher.publish(...).
from command bus execute method to default publisher and instead add this._publisher.publish(...) there. This way it would work fine for both default and custom publisher.
Is there an existing issue for this?
Current behavior
Hi,
I wanted to use custom publisher for commands, events and queries, but it doesn't work. If I connect my own publisher in
onModuleInit
methodthis.command$.publisher = this.commandPublisher;
and then in a controller callthis.commandBus.execute(...)
, my publisher won't be called, because this publisher is never called in the command bus class. To make it work, I have to manually callthis.commandBus.publisher.publish(...)
.Minimum reproduction code
https://github.com/nestjs/cqrs/blob/master/src/command-bus.ts
Steps to reproduce
No response
Expected behavior
I think we should move these two lines
from command bus
execute
method to default publisher and instead addthis._publisher.publish(...)
there. This way it would work fine for both default and custom publisher.And the same applies to query bus.
Package version
8.0.1
NestJS version
8.2.3
Node.js version
No response
In which operating systems have you tested?
Other
No response