QueryResult<T>.from constructor

QueryResult<T>.from(
  1. StatedResult result
)

Create QueryResult from any other result

FailedResult converts to QueryResult.failed SucceededResult. InitialValueResult with type T converts to QueryResult.succeeded Otherwise UnsupportedError is thrown

Implementation

factory QueryResult.from(StatedResult result) =>
    result.unsafeMapOr<T, QueryResult<T>>(
      failedResult: (result) =>
          QueryResult.failed(result.error, result.stackTrace),
      hasValue: (result) => QueryResult.succeeded(result.value),
      orElse: () =>
          throw UnsupportedError("Cannot convert $result to QueryResult<$T>"),
    );