where method

StreamObservable<T> where(
  1. bool predicate(
    1. T data
    )
)

Filters the stream using a predicate function.

Implementation

StreamObservable<T> where(bool Function(T data) predicate) {
  throwIfDisposed('filter stream');
  if (_stream == null) {
    throw StateError('Call listen() first before using where()');
  }

  final newObs = StreamObservable<T>();
  final filtered = _stream!.where(predicate);
  newObs.listen(filtered);
  return newObs;
}