subscribeToAll method

Future<EventStreamSubscription> subscribeToAll({
  1. LogPosition? position,
  2. bool resolveLinks = false,
  3. UserCredentials? userCredentials,
  4. SubscriptionFilterOptions? filterOptions,
  5. SubscriptionResolvedEventCallback? onEventAppeared,
  6. SubscriptionDroppedCallback? onSubscriptionDropped,
  7. EventStoreClientOperationOptions? operationOptions,
})

Subscribe to all ResolvedEvents.

Starting with first event after optional position. When position is not given, all events from LogPosition.start is returned. Use resolveLinks to resolve links as ResolvedEvent (default is false).

Callback SubscriptionResolvedEventCallback is invoked and awaited when a new event is received over the subscription.

Callback SubscriptionDroppedCallback is invoked and awaited when the subscription is dropped.

Returns as EventStreamSubscription on first response from the server.

Implementation

Future<EventStreamSubscription> subscribeToAll({
  LogPosition? position,
  bool resolveLinks = false,
  UserCredentials? userCredentials,
  SubscriptionFilterOptions? filterOptions,
  SubscriptionResolvedEventCallback? onEventAppeared,
  SubscriptionDroppedCallback? onSubscriptionDropped,
  EventStoreClientOperationOptions? operationOptions,
}) async {
  return $runRequest<EventStreamSubscription>(() async {
    final request = _setSubscriptionReq(
      toReadAllReq(
        position ?? LogPosition.start,
        resolveLinks: resolveLinks,
      ),
      filterOptions,
    );
    final client = await $getClient();
    final resultStream = client.read(
      request,
      options: $getOptions(
        userCredentials: userCredentials,
        operationOptions: operationOptions,
        timeoutAfter: toSubscriptionTimeout(operationOptions),
      ),
    );
    return _toSubscriptionResult(
      StreamState.all(position),
      resultStream,
      onEventAppeared: onEventAppeared,
      onSubscriptionDropped: onSubscriptionDropped,
      checkpointReached: filterOptions?.checkpointReached,
    );
  });
}