whereType<S> method

Observable<S> whereType <S>()

This transformer is a shorthand for Stream.where followed by Stream.cast.

Events that do not match T are filtered out, the resulting Observable will be of Type T.

Example

Observable.fromIterable([1, 'two', 3, 'four'])
  .whereType<int>()
  .listen(print); // prints 1, 3

as opposed to:

Observable.fromIterable([1, 'two', 3, 'four'])
  .where((event) => event is int)
  .cast<int>()
  .listen(print); // prints 1, 3

Implementation

Observable<S> whereType<S>() => transform(WhereTypeStreamTransformer<T, S>());