GraphReFlyTS

API Reference

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

import { timeout } from "@graphrefly/ts/operators";

Signature

function timeout(
	source: Node<S>,
	ms: number,
): Node<S>

Parameters

ParameterTypeDescription
sourceNode<S>Source node that provides graph-visible input.
msnumberDuration or timestamp in milliseconds.

Returns

A Node<S> value.

Example

import { timeout } from "@graphrefly/ts/operators";

Source

packages/ts/src/graph/time.ts