observeEvents<E extends GeneratedMessage> method

Future<EventSubscription<E>> observeEvents<E extends GeneratedMessage>()

Creates an event subscription for events produced as a direct result of this command.

Events down the line, i.e. events produced as the result of other messages which where produced as the result of this command, do not match this subscription.

When the resulting future completes, the subscription is guaranteed to be created. Also, when the future created in post(..) completes, the all subscriptions created within the same CommandRequest are guaranteed to have completed.

Implementation

Future<EventSubscription<E>> observeEvents<E extends GeneratedMessage>() {
    var subscription = _client.subscribeToEvents<E>()
        .where(eq('context.past_message', _commandAsOrigin()))
        .post();
    _futureSubscriptions.add(subscription);
    return subscription;
}