mapValue<TR> method Null safety

AsyncQueryResult<TR> mapValue<TR>(
  1. ValueMapper<T, TR> mapper
)

map the value of query. If it is a SucceededResult or InitialValueResult, map its value with mapper. Otherwise, keep the result.

Implementation

AsyncQueryResult<TR> mapValue<TR>(
  ValueMapper<T, TR> mapper,
) =>
    mapOr(
      succeeded: (r) => AsyncQueryResult.succeeded(mapper(r.value)),
      initialValue: (r) => AsyncQueryResult.initialValue(mapper(r.value)),
      failed: (r) => AsyncQueryResult.failed(r.error, r.stackTrace),
      orElse: () => this as AsyncQueryResult<TR>,
    );