bindStream method

StreamSubscription<T> bindStream(
  1. Stream<T> stream, {
  2. void onError(
    1. Object error,
    2. StackTrace stackTrace
    )?,
  3. void onDone()?,
  4. bool? cancelOnError,
})

Implementation

StreamSubscription<T> bindStream(
  Stream<T> stream, {
  void Function(Object error, StackTrace stackTrace)? onError,
  void Function()? onDone,
  bool? cancelOnError,
}) {
  _subscription?.cancel();
  final sub = stream.listen(
    (data) {
      value = data;
    },
    onError: onError,
    onDone: onDone,
    cancelOnError: cancelOnError,
  );
  _subscription = sub;
  return sub;
}