BoundedStreamBridge<T> constructor
BoundedStreamBridge<T> ({
- required Stream<
T> source(), - required int weigh(
- T
- required StreamBufferLimits limits,
- StreamBridgeStats? stats,
- bool pauseSource = true,
- bool deferStart = true,
- void onStart()?,
- Object overflowError()?,
- Object sourceError()?,
- Object elementError()?,
- void onClosed()?,
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),
);
}