combine<R> method

Result<R> combine<R>(
  1. R combine(
    1. A a,
    2. B b,
    3. C c,
    4. D d,
    )
)

Combines the data of all Results into a single Result, using the provided combine function.

If all of the results hasData, the returned Result will contain the combined data.

If all of the Results are Data, the return value will also be Data. If any of the Results are Error, the return value will be an Error that contains the error object of the first encountered error. Loading will be returned if at least one result was Loading, and there was no Error.

Implementation

Result<R> combine<R>(R Function(A a, B b, C c, D d) combine) {
  return [$1, $2, $3, $4].combine((data) => combine(data[0] as A, data[1] as B, data[2] as C, data[3] as D));
}