API Reference
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
import { onFirstData } from "@graphrefly/ts/operators";
Signature
function onFirstData(
fn: (v: S) => void,
opts?: { where?: (v: S) => boolean },
): Operator<S, S>
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
A Operator<S, S> value.
Example
import { onFirstData } from "@graphrefly/ts/operators";
Source
packages/ts/src/graph/operators.ts