foldFuture<TR> method

Future<TR> foldFuture<TR>(
  1. Future<TR> invalid(
    1. Iterable<Fail> failures
    ),
  2. Future<TR> valid(
    1. T val
    )
)

Implementation

Future<TR> foldFuture<TR>(Future<TR> Function(Iterable<Fail> failures) invalid,
                                                Future<TR> Function(T val) valid)
{

  return then((value) => value.fold((failures) => invalid(failures).then((value) => value),
                                    (val)       => valid(val).then((value) => value)));
}