listen method

MiniSubscription<T> listen(
  1. void onData(
    1. T event
    ), {
  2. Function? onError,
  3. void onDone()?,
  4. bool cancelOnError = false,
})

Listens for events on the stream.

Implementation

MiniSubscription<T> listen(
  void Function(T event) onData, {
  Function? onError,
  void Function()? onDone,
  bool cancelOnError = false,
}) {
  final MiniSubscription<T> subs = MiniSubscription<T>(
    onData,
    onError,
    onDone,
    cancelOnError,
    listenable,
  );
  listenable.addListener(subs);
  return subs;
}