Future

Overview

The Future object provides a simple and powerful interface for accessing the eventual result of an asynchronous operation.

Fields

.then

fn [V = Any](callback: fn (T) -> V | Future[V]) -> Future[V]

Registers a callback to be called when this future is resolved.

.fails

fn (callback: fn (Any?) -> T | Future[T]) -> Future[T]

Registers a callback to be called when this future is rejected.

.await

fn -> T

Pauses execution of the current thread isolate until the future is fulfilled.

.state

fn -> Number

Gets the current state of a Future.

Statics

.async

fn [F: Function](callback: F, ...args: Any) -> Any

Spawns a Future from the given callback and arguments.

.delay

fn (millis?: Number, callback?: fn -> Void) -> Future[Void]

Spawns a Future that runs its callback after a given delay.

.resolve

fn [T](value: T) -> Future[T]

Creates a Future already resolved with a value.

.reject

fn [T = Any](error?: Any) -> Future[T]

Creates a Future already rejected with an error.

On this page