method AsyncResult.from
AsyncResult.from<T, E extends BaseError>(promise: Promise<Result<T, E>>): AsyncResult<T, E>

Creates an AsyncResult from a Promise of Result.

Examples

Example 1

const asyncResult = AsyncResult.from(fetchData());

Type Parameters

The type of the success value

E extends BaseError

The type of the error

Parameters

promise: Promise<Result<T, E>>

The promise that resolves to a Result

Return Type

An AsyncResult wrapping the promise

Usage

import { AsyncResult } from "result/mod.ts";