Uneventful
    Preparing search index...

    An asynchronously-expected result (usually produced by a Task) that can be awaited, yielded to, or queried.

    Futures implement the Promise interface (then, catch, and finally), so they can be passed to Promise-using APIs or awaited by async functions. They also implement Yieldable, so you can await their results using yield *.

    In addition to those asynchronous query/callback methods, they also have the reactive query and synchronous callback methods provided by ObservableResult.

    Note: Synchronous callbacks are run in FIFO order before any asynchronous callbacks, but after the producing task's cleanup callbacks have run (if applicable).

    interface Future<T> extends Promise<T>, Yieldable<T>, ObservableResult<T> {}

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index

    Obtaining Results

    • An iterable suitable for use with yield * (in a coroutine) to obtain a result.

      Returns Coroutine<T>

    • Invoke a callback with the result.

      Callbacks are executed in FIFO order after any cleanups for the producing task have run, and before any asynchronous (Promise) callbacks run. You should only use this (and other Future methods) to obtain a result, not to perform cleanups. (That's what .Context.must() and .Context.release() callbacks are for.)

      Parameters

      • action: (res: Result<T>) => unknown

      Returns this

      The .onError(), .onValue(), and .onCancel() methods provide shortcuts for creating do callbacks that only run under specific end conditions.

    • Invoke a callback if the producing task is canceled.

      This is shorthand for a .do() callback that checks for a cancellation, so it uses the same relative order and runs in the same group as other .do callbacks.

      Parameters

      • cb: () => unknown

        The callback run on cancellation

      Returns this

    • Invoke a callback upon result if the result is an error.

      This is shorthand for a .do() callback that checks for an error and marks it handled, so it uses the same relative order and runs in the same group as other .do callbacks.

      Parameters

      • cb: (err: any) => unknown

        A callback that will receive the error

      Returns this

    • Invoke a callback upon result if the result is a success/value.

      This is shorthand for a .do() callback that checks for a success/value result, so it uses the same relative order and runs in the same group as other .do callbacks.

      Parameters

      • cb: (val: T) => unknown

        A callback that will receive the value

      Returns this

    • The result of the future (canceled, returned value, or error), or undefined if there's no result yet.

      If undefined, this also acts as a reactive value: the calling reactive function or effect (if any) will recalculate when the future settles, with the updated result.

      Returns Result<T> | undefined

    Other

    "[toStringTag]": string
    • Attaches a callback for only the rejection of the Promise.

      Type Parameters

      • TResult = never

      Parameters

      • Optionalonrejected: ((reason: any) => TResult | PromiseLike<TResult>) | null

        The callback to execute when the Promise is rejected.

      Returns Promise<T | TResult>

      A Promise for the completion of the callback.

    • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

      Parameters

      • Optionalonfinally: (() => void) | null

        The callback to execute when the Promise is settled (fulfilled or rejected).

      Returns Promise<T>

      A Promise for the completion of the callback.

    • Attaches callbacks for the resolution and/or rejection of the Promise.

      Type Parameters

      • TResult1 = T
      • TResult2 = never

      Parameters

      • Optionalonfulfilled: ((value: T) => TResult1 | PromiseLike<TResult1>) | null

        The callback to execute when the Promise is resolved.

      • Optionalonrejected: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null

        The callback to execute when the Promise is rejected.

      Returns Promise<TResult1 | TResult2>

      A Promise for the completion of which ever callback is executed.