Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add observeOneOf(...) method to CommandRequest #126

Open
dmitrykuzmin opened this issue Dec 12, 2019 · 0 comments
Open

Add observeOneOf(...) method to CommandRequest #126

dmitrykuzmin opened this issue Dec 12, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@dmitrykuzmin
Copy link
Contributor

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.

@dmitrykuzmin dmitrykuzmin added the enhancement New feature or request label Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant