Skip to content

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

@dmitrykuzmin

Description

@dmitrykuzmin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions