withLatestFromResult<R> method

Stream<Result<R>> withLatestFromResult<R>(
  1. Stream<Result<R>> stream,
  2. R mapSuccess(
    1. E,
    2. R
    ), {
  3. String? tag,
})

Map the current stream to a new Result stream, as combining it with another stream.

Use mapSuccess to map the current stream with the given stream to a new Result stream.

Example:

Result<String> result = Stream.value(0).withLatestFromResult<String>(
    Stream.value(Result.success('1')),
    (value, resultValue) => '$value, $resultValue', //0, 1
);

Implementation

Stream<Result<R>> withLatestFromResult<R>(
  Stream<Result<R>> stream,
  R Function(E, R) mapSuccess, {
  String? tag,
}) =>
    withLatestFrom<Result<R>, Result<R>>(
      stream,
      (e, t) => t.mapResult((data) => mapSuccess(e, data), tag: tag),
    );