onFirstData()
onFirstData (alias tapFirst): invoke fn exactly once on the first qualifying value (default
where: v => v != null — null/undefined pass through without counting as “first”), then pass all
values through unchanged. The one-shot guard is per-node ctx.state (NOT a factory closure, so a
second instantiation of the same factory re-arms — R-ctx-state).
Import
Section titled “Import”import { onFirstData } from "@graphrefly/ts/operators";Signature
Section titled “Signature”function onFirstData( fn: (v: S) => void, opts?: { where?: (v: S) => boolean },): Operator<S, S>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fn | (v: S) => void | Synchronous function invoked by the helper. |
opts | { where?: (v: S) => boolean } | Options that configure the helper. |
Returns
Section titled “Returns”A Operator<S, S> value.
Example
Section titled “Example”import { onFirstData } from "@graphrefly/ts/operators";Source
Section titled “Source”packages/ts/src/graph/operators.ts