combineWith<B> method

FutureValue<(A, B)> combineWith<B>(
  1. FutureValue<B> other
)

Implementation

FutureValue<(A, B)> combineWith<B>(FutureValue<B> other) {
  final self = this;
  if (self is FutureError<A>) {
    return FutureValue.error(self.error, self.stackTrace);
  } else if (other is FutureError<B>) {
    return FutureValue.error(other.error, other.stackTrace);
  }

  final loading = isLoading || other.isLoading;
  final data = (dataOrNull != null && other.dataOrNull != null)
      // ignore: null_check_on_nullable_type_parameter
      ? (dataOrNull!, other.dataOrNull!)
      : null;

  return loading || data == null
      ? FutureValue.loading(data)
      : FutureValue.data(data);
}