timeout()
timeout: idle watchdog — forward every source value, but ERROR if more than ms elapses with no
value (RxJS timeout(ms), first === each === ms). SUBSCRIBE-ARMED: the first timer(ms) is a
CONSTRUCTION-time dep, so it arms when timeout’s node is subscribed/activated (a depless source
runs lazily on _activate) — i.e. a source that never emits its FIRST value within ms still
errors. A dep-bearing operator body never runs at activation (only depless nodes do, node.ts), which
is why this is a HELPER returning a Node, not a g.initNode(op, [source]) operator.
Each source value forwards as-is and RESETS the idle timer (unsubscribeDep the current timer(ms),
subscribeDep a fresh one — its onDeactivation clearTimeout cancels the prior countdown). The timer
firing (its DATA/COMPLETE) is the timeout → [[ERROR]]. Source COMPLETE forwards COMPLETE (no
error) and removes the idle timer during the terminal wave (D62 terminal-drains-queued-rewire);
a source ERROR forwards likewise. The idle timer is also torn down when the consumer unsubscribes
(timeout deactivates → dep unsub → timer onDeactivation). Self-catching (D30).
Import
Section titled “Import”import { timeout } from "@graphrefly/ts/operators";Signature
Section titled “Signature”function timeout( source: Node<S>, ms: number,): Node<S>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
source | Node<S> | Source node that provides graph-visible input. |
ms | number | Duration or timestamp in milliseconds. |
Returns
Section titled “Returns”A Node<S> value.
Example
Section titled “Example”import { timeout } from "@graphrefly/ts/operators";Source
Section titled “Source”packages/ts/src/graph/time.ts