In real-life use cases it is a common occurrence to expect an event OR a rejection of a certain type after posting a command.
With the current API, we can observe multiple command results simultaneously by calling the CommandRequest.observe(...) method multiple times, but this process is verbose and inconvenient.
While for Java client, where we have a slightly different API, this would not be as straightforward/beneficial, in our JS client we could add a method like:
Client.observeOneOf(eventTypes, consumer)
which would allow behavior like:
client.command(cmd)
// ...
.observeOneOf([UserLoggedIn, UserLogInDenied], ({subscribe, unsubscribe}) => {
subscribe(event => _doSomethingWithEventOrRejection(event, unsubscribe));
})
A code construction like this would be much less complicated and verbose than what we need to implement now to achieve the same purpose.
In real-life use cases it is a common occurrence to expect an event OR a rejection of a certain type after posting a command.
With the current API, we can observe multiple command results simultaneously by calling the
CommandRequest.observe(...)method multiple times, but this process is verbose and inconvenient.While for Java client, where we have a slightly different API, this would not be as straightforward/beneficial, in our JS client we could add a method like:
which would allow behavior like:
A code construction like this would be much less complicated and verbose than what we need to implement now to achieve the same purpose.