Optional knobs accepted by Graph.subscribe and Graph.subscribeMany (#766).

The bar for adding a field here is the same as for adding a public method on Graph: name an unavoidable concept the engine cannot express without it. transient clears that bar — adopters routinely want a "fire once then unmount" observer to react to a one-shot derived signal (e.g. SSR-hydrate completion, a commitMetadataDerived that publishes "the just-completed commit is the one I was waiting for") without leaking a manual unsubscribe() into every consumer call site. The engine drops a transient observer at the end of the same commit pass that fired it, so subsequent commits never see it again.

interface SubscribeOptions {
    transient?: boolean;
}

Properties

Properties

transient?: boolean

When true, the observer is registered as a one-shot: the engine fires it on the first commit whose Phase G dispatch passes the usual Object.is equality cutoff for the observed node, then auto-disposes the registration before the commit returns. A subsequent commit on the same graph never sees the observer again.

Subtleties:

  • If the registration's value never changes, the observer never fires and the registration is never auto-disposed. transient is "fire at most once," not "exists for at most one commit." A caller that needs the latter constructs a normal subscription and unsubscribes from inside the observer.
  • The synchronous initial fire from Graph.subscribe does NOT count as the transient observer's fire — initial fire is always synchronous from the call to subscribe, and its purpose is to surface the current value to the new observer, not to satisfy the one-shot contract. The engine treats the initial fire as bookkeeping (hasFired flips), and the auto-dispose trigger is the next Phase G fire.
  • On Graph.subscribeMany, transient applies to the whole group: the observer fires on the first commit during which any of the registered nodes' values changed, and the entire group is dropped at the end of that commit.

Defaults to false — the engine retains the registration across commits as the canonical Graph.subscribe contract requires.