pause method

void pause([
  1. Future<void>? resumeSignal
])
inherited

Pauses delivery of notifications to handleNotification until a matching resume (or completion of resumeSignal).

Notifications received while paused are buffered inside this mixin and delivered, in arrival order, when the pause depth returns to zero. The mixin does NOT pause the underlying notification subscription, because that subscription sits on a broadcast stream and pausing a broadcast subscription would silently drop events emitted during the pause window.

If resumeSignal is provided, the pause is undone when the future completes (success or error), as if by a call to resume. Errors on resumeSignal are not propagated.

If the subscription is paused more than once, an equal number of resumes must be performed before delivery resumes. Calls to resume and the completion of a resumeSignal are interchangeable - the pause which was passed a resumeSignal may be ended by a call to resume, and completing the resumeSignal may end a different pause.

It is safe to resume or complete a resumeSignal even when the subscription is not paused; the call has no effect.

Implementation

void pause([Future<void>? resumeSignal]) {
  _logger.finer('KeyStream pause (depth ${_pauseCount + 1})');
  _pauseCount++;
  if (resumeSignal != null) {
    resumeSignal.then(
      (_) => resume(),
      onError: (Object _, [StackTrace? __]) => resume(),
    );
  }
}