Constructor
new CommandRequest(commandMessagenon-null, clientnon-null, actorRequestFactorynon-null)
Parameters:
Name | Type | Description |
---|---|---|
commandMessage |
Message | the command to post |
client |
Client | the client which initiated the request |
actorRequestFactory |
ActorRequestFactory | the request factory |
- Source:
Classes
Methods
observe(eventTypenon-null, consumernon-null) → {this}
Adds the event type to the list of observed command handling results.
Parameters:
Name | Type | Description |
---|---|---|
eventType |
Class.<Message> | a type of the observed events |
consumer |
consumerCallback.<EventSubscriptionCallbacks> | a consumer of the `subscribe` and `unsubscribe` callbacks which are responsible for accepting the incoming events and cancelling the subscription respectively |
- Source:
Returns:
self for method chaining
- Type
- this
onError(callbacknon-null) → {this}
Runs the callback if the command could not be handled by the Spine server due to a
technical error.
Parameters:
Name | Type | Description |
---|---|---|
callback |
consumerCallback.<CommandHandlingError> | the callback to run |
- Source:
Returns:
self for method chaining
- Type
- this
onImmediateRejection(callbacknon-null) → {this}
Runs the callback if the server responded on a command with an immediate rejection.
The immediate rejection means the command did not pass the command filters set up in the
bounded context and was disqualified from execution right away.
A typical example of this would be the command not passing filters due to user permissions
being not broad enough.
Please note that this rejection is different to a "normal" rejection when the command is
acknowledged with the `OK` status and then reaches the handler method which processes it. Such
rejections can be tracked using the `observe(...)` method of this request.
Parameters:
Name | Type | Description |
---|---|---|
callback |
consumerCallback.<spine.core.Event> |
- Source:
Returns:
self for method chaining
- Type
- this
onOk(callbacknon-null) → {this}
Runs the callback if the command is successfully handled by the Spine server.
Parameters:
Name | Type | Description |
---|---|---|
callback |
parameterlessCallback | the callback to run |
- Source:
Returns:
self for method chaining
- Type
- this
post() → {Promise.<void>}
Posts the command to the server and subscribes to all observed types.
- Source:
Returns:
a promise that signals if the command posting was done successfully,
may be ignored
- Type
- Promise.<void>