waitUntil method

Future<T> waitUntil(
  1. bool predicate(
    1. T
    )
)

Implementation

Future<T> waitUntil(bool Function(T) predicate) async {
  // short-circuit if predicate already satisfied
  if (predicate($)) return $;
  // otherwise, run predicate on every change
  await for (T value in this.stream) {
    if (predicate(value)) break;
  }
  return $;
}