BoundedStreamBridge<T> constructor

BoundedStreamBridge<T>({
  1. required Stream<T> source(),
  2. required int weigh(
    1. T
    ),
  3. required StreamBufferLimits limits,
  4. StreamBridgeStats? stats,
  5. bool pauseSource = true,
  6. bool deferStart = true,
  7. void onStart()?,
  8. Object overflowError()?,
  9. Object sourceError(
    1. Object,
    2. StackTrace
    )?,
  10. Object elementError(
    1. Object,
    2. StackTrace
    )?,
  11. void onClosed(
    1. int,
    2. int,
    3. Object?
    )?,
})

Starts source on first listen, by default on the next microtask.

Implementation

BoundedStreamBridge({
  required Stream<T> Function() source,
  required int Function(T) weigh,
  required StreamBufferLimits limits,
  StreamBridgeStats? stats,
  bool pauseSource = true,
  bool deferStart = true,
  void Function()? onStart,
  Object Function()? overflowError,
  Object Function(Object, StackTrace)? sourceError,
  Object Function(Object, StackTrace)? elementError,
  void Function(int, int, Object?)? onClosed,
}) : _weigh = weigh,
     _limits = limits,
     _stats = stats,
     _pauseSource = pauseSource,
     _deferStart = deferStart,
     _onStart = onStart,
     _overflowError = overflowError,
     _sourceError = sourceError,
     _elementError = elementError,
     _onClosed = onClosed,
     _budget = RpcBufferBudget(
       limitBytes: limits.bytes,
       limitEvents: limits.items,
     ) {
  _input = StreamSource<T>(
    source: source,
    onData: _receive,
    onError: _failed,
    onDone: _sourceDone,
    pauseBroadcast: false,
  );
  _out = StreamController<T>(
    sync: true,
    onListen: _listen,
    onPause: _pause,
    onResume: _resume,
    onCancel: () => _finish(notify: false),
  );
}