We are enhancing the documentation for this. I spent the better part of yesterday chasing a race condition because I didn’t know that when you emit an event inside a command handler, the event handler callback happens concurrently and instantly. I was emitting somewhere in the middle of my code and was assuming my current state was stable throughout the command handler and it was not. Always emit at the bottom of the command handler, just before returning Empty etc.
According to Peter Vluger the answer is no if I’m understanding what he said here from a slack conversation:
" Note that applying event handlers immediately on
thenReply or similar method could be provided, which takes the updated state and returns the response. This would be similar to the Akka Typed event sourced behaviour.
That is even an open issue over here for some time:
looking forward to get that merged back there too when changed.