Closed emmkong closed 7 years ago
No, but pre-contitions or pre-load-conditions are. And worst case you can fefine your own commandHandler: https://github.com/adrai/node-cqrs-domain/blob/master/README.md#command-handler-be-careful
Hi Adrai, is this by design? please advise the reason behind this? else I could submit a pull request to change this.
In theory handling a command should never by async... the command/aggregate should have all information to ensure the business rules. That's why I do not recommend to do it async.
Ok, I got what you mean. I raised this issue as we has a some business logic code that written in a promise pattern that hard to integrate. Now we had rewrite it to fit this design. Thanks for your comment.
@adrai Sorry, I don't get your post that a command should never be async...what if I have to download a file and then send an event after the download has finished? I'm quite new to CQRS...so do I have wrong thinking? Thanks
I don't think downloading a file is a business behaviour... so I wouldn't implement it in the domain. You don't have to solve everything the CQRS way ;-) I would download the file in a microservice or saga and then generate a command containing the business relevant information.
Thanks for the clarification!
I wonder will it possible that a command handler function could be async?
for example: