resolveBoth<R> method

FutureOr<R> resolveBoth<R>(
  1. FutureOr<T> other,
  2. FutureOr<R> resolver(
    1. T val1,
    2. T val2
    )
)

Resolves this and other with resolver.

Note that the parameter other should be of the same Type of this instance.

See also resolveOther.

Implementation

FutureOr<R> resolveBoth<R>(
    FutureOr<T> other, FutureOr<R> Function(T val1, T val2) resolver) {
  var self = this;

  if (self is Future<T>) {
    if (other is Future<T>) {
      return self.then((v1) {
        return other.then((v2) => resolver(v1, v2));
      });
    } else {
      return self.then((v1) {
        return resolver(v1, other);
      });
    }
  } else {
    if (other is Future<T>) {
      return other.then((v2) => resolver(self, v2));
    } else {
      return resolver(self, other);
    }
  }
}