Object returned by resource; pairs the engine node with imperative triggers for the host application.

The handle does not schedule fetches itself. Callers decide when to call ResourceHandle.fetch, ResourceHandle.invalidate, or ResourceHandle.fail; each of those produces exactly one commit on the underlying graph (one GraphTime advance).

interface ResourceHandle<T> {
    key: string;
    node: Node<ResourceState<T>>;
    fail(error: unknown): void;
    fetch(): Promise<T>;
    invalidate(): void;
}

Type Parameters

  • T

    Resolved value type produced by the loader.

Properties

Methods

Properties

key: string

The NodeId the resource was registered under. Stable for the lifetime of the handle.

The engine node carrying the current ResourceState.

Methods

  • Drive the chart-named Loading | Loaded → Errored edges from the host application (e.g. an out-of-band websocket pushing a server-side error for an already-Loaded resource, or a host that cancels an in-flight fetch and wants the resource parked in errored instead of loading).

    Parameters

    • error: unknown

    Returns void

    Throws ForbiddenResourceTransitionError when the current state is idle, stale, or errored — the chart has no edge into Errored from any of those.

  • Begin or restart the load. Returns the resolved value (or rejects on error).

    Returns Promise<T>

  • Mark the current Loaded state as Stale (without refetching yet).

    Returns void