Uneventful
    Preparing search index...

    ObservableResult<T>

    Reactive queries and synchronous callbacks for a present or future Result

    interface ObservableResult<T> {
        do(action: (res: Result<T>) => unknown): this;
        onCancel(cb: () => unknown): this;
        onError(cb: (err: any) => unknown): this;
        onValue(cb: (val: T) => unknown): this;
        result(): Result<T> | undefined;
    }

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index

    Obtaining Results

    Obtaining Results

    • 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