listen method

  1. @override
StreamSubscription<Store> listen(
  1. StoreHandler? onData, {
  2. Function? onError,
  3. void onDone()?,
  4. bool? cancelOnError,
})
override

Adds a subscription to this Store.

Each time this Store triggers (by calling trigger), indicating that data has been mutated, onData will be called.

If the Store has been disposed, this method throws a StateError.

It is the caller's responsibility to cancel the subscription when needed.

Implementation

@override
StreamSubscription<Store> listen(StoreHandler? onData,
    {Function? onError, void onDone()?, bool? cancelOnError}) {
  if (isDisposed) {
    throw StateError('Store of type $runtimeType has been disposed');
  }

  return _stream.listen(onData,
      onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}