cond method

FutureOr<T> cond(
  1. bool test(
    1. T value
    )
)

Returns the value of the Pod when the test returns true.

Implementation

FutureOr<T> cond(bool Function(T value) test) {
  final completer = CompleterOr<T>();
  void check() {
    if (test(value)) {
      completer.complete(value);
    }
  }

  check();
  if (completer.isCompleted) {
    return value;
  } else {
    // ignore: deprecated_member_use_from_same_package
    addListener(check);
    return consec(completer.futureOr, (e) {
      removeListener(check);
      return e;
    });
  }
}