Future<T>

A lazy asynchronous computation. Calling an async fn or building a continuation does not start work; the first await or spawn starts the upstream computation exactly once.

Methods

Future<T>.then<U>(fn(T) -> U) -> Future<U>#
Future<T>.then<U>(fn(T) -> Future<U>) -> Future<U>

Runs once on upstream success in a scheduler task. Returning Future<U> flattens exactly one layer; failure bypasses the callback.

Future<T>.catch(fn(AsyncError) -> T) -> Future<T>#
Future<T>.catch(fn(AsyncError) -> Future<T>) -> Future<T>

Runs once on a retained runtime failure and recovers to the upstream success type. Returning Future<T> flattens exactly one layer; success bypasses the callback.

AsyncError

Future.catch receives a retained runtime failure with these stable fields:

name: string#
message: string#
file: string#
line: int#
column: int#
trace: string#

Expected application failures should use Result<T, Error>; catch recovers asynchronous runtime diagnostics.