asyncWhere<T> function

Stream<T> asyncWhere<T>(
  1. List<T> items,
  2. Future<bool> filter(
    1. T item
    )
)

Returns a single-subscription stream of the items for which the filter returns a future that completes with true. The stream fires an event for an item only when its future completes with true AND the filter futures for all previous items have completed.

Example: familyBlackSheep = asyncWhere(children, growsUpRotten);

Implementation

Stream<T> asyncWhere<T>(List<T> items, Future<bool> filter(T item)) async* {
  for (var item in items) {
    if (await filter(item)) {
      yield item;
    }
  }
}