Events and commands are designed to decouple the modules from each other.
Module A does not explicitly know about module B, it only generates an event on application.vent
, for example, to register, then module B listens for this event and redirects the browser page to success.
The same with the commands, but more suitable for the situation when you need some information to continue, for example, after a successful login, when you find out the name of the user who is logged in. If you do not want to obtain user credentials, register the command in module A, and then modules B and C can restore it from its specific implementation.
source share