Closed danaki closed 6 years ago
HI @danaki
Your application is either aware a call is made async or sync, i tend to believe this is a design-choice of your app. Typically user registration happens in sync.
On the technical side, yes we can benefit from return values coming from message handlers when we use Symfony Messenger (i never did that though using SimpleBus). I.e.
$userId = $bus->handle(new CreateUserCommand($data = $form->getData()));
Cosmetically we can add return values anyway, to be leveraged when using SF Messenger. It's on my list to switch the demo app to do so.
Alternatively, and this is my common approach, is to generate the user UUID upfront.
$userId = new UserId();
$bus->handle(new CreateUserCommand(['id' => $userId] + $data = $form->getData()));
Assuming we can close but feel free to re-open :)
An example code from RegisterController:
If I understand CreateUserCommand() doesn't imply an intermediate result (or throws an Exception?). And even can be handled delayed in asynchronous way, then how to deal with this situation from a web application point of view? Should controller be aware is it setup to be asynchronous or should a client request flash messages repeatedly in a separate REST call?