resolveOther<R, E> method

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

Resolves this and other with resolver.

This method is similar to resolveBoth, but accepts an other parameter with a different Type of this instance.

Implementation

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

  if (self is Future<T>) {
    if (other is Future<E>) {
      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<E>) {
      return other.then((v2) => resolver(self, v2));
    } else {
      return resolver(self, other);
    }
  }
}