attach method

void attach()

Resumes forwarding events from the source stream.

Normally called automatically when the stream gets the first subscription. You may want to call this method manually after a call to detach().

Implementation

void attach() {
  assert(detachCount >= 0,
      "A call to `attach()` should follow a call to `detach()` (nesting is allowed)");
  detachCount -= 1;

  if (detachCount < 0 &&
      _streamController!.hasListener &&
      _sourceSubscription == null) {
    log("ATTACH");
    try {
      _sourceSubscription = _onListenEmitFrom().listen(
        _streamController!.add,
        onError: _streamController!.addError,
        onDone: _streamController!.close,
      );
    } on Exception catch (e, s) {
      _streamController!.addError(e, s);
    }
  }
}