menu
Promise
import { Promise } from "destack:async";
Value produced by asynchronous execution.
A promise never rejects in Destack: recoverable failure remains an explicit Result value,
and panic remains the Worker fault boundary.
Every observer receives the same copyable value.
1export class Promise<T: Copy> {2 constructor(executor: ((T) => void) => void);3 then<U: Copy>(onFulfilled: (T) => Promise<U>): Promise<U>;4 then<U: Copy>(onFulfilled: (T) => U): Promise<U>;5 finally(onFinally: () => Promise<void>): Promise<T>;6 finally(onFinally: () => void): Promise<T>;7 static resolve<T: Copy>(value: Promise<T>): Promise<T>;8 static resolve<T: Copy>(value: T): Promise<T>;9 static all<T: Copy>(values: Iterable<T | Promise<T>>): Promise<T[]>;10 static race<T: Copy>(values: Iterable<T | Promise<T>>): Promise<T>;11 static withResolvers<T: Copy>(): PromiseResolvers<T>;12 static block<T: Copy>(promise: Promise<T>): T;13}Members
constructor(executor: ((T) => void) => void)Create a promise from an eager executor.
then<U: Copy>(onFulfilled: (T) => Promise<U>): Promise<U>Continue when the promise fulfills, adopting the returned promise.
finally(onFinally: () => Promise<void>): Promise<T>Continue after the promise fulfills, adopting the returned promise.
finally(onFinally: () => void): Promise<T>Continue after the promise fulfills, keeping the value.
static race<T: Copy>(values: Iterable<T | Promise<T>>): Promise<T>Wait for the first fulfilled promise.
static withResolvers<T: Copy>(): PromiseResolvers<T>Create a promise with an exposed resolving function.