where method

ReactiveSubject<T> where(
  1. bool test(
    1. T event
    )
)

Filters the items emitted by the source ReactiveSubject by only emitting those that satisfy a specified predicate.

Usage:

final subject = ReactiveSubject<int>(initialValue: 1);
final evens = subject.where((i) => i % 2 == 0);
evens.stream.listen(print);
subject.add(2); // Prints: 2
subject.add(3); // Does not print

Implementation

ReactiveSubject<T> where(bool Function(T event) test) {
  final result = ReactiveSubject<T>();
  stream.where(test).listen(result.add, onError: result.addError);
  return result;
}