GraphReFlyTS

API Reference

repeat()

repeat: play a source count times in sequence (RxJS repeat). A DEPLESS self-driving operator (Operator<never, S>, instantiate via g.initNode(repeat(factory, count), [])) — NOT a dep-operator.

It takes a factory: () => NodeInput<S> (a RECIPE), not a source Node, because clean-slate Nodes are HOT/shared (multicast + cache): re-subscribing the SAME node replays its cache, it does not re-RUN the source. RxJS repeat re-subscribes the COLD source = a fresh subscription each round; the clean-slate analogue is a fresh node per round → a factory. (A repeat(count)-over-a-Node shape remains deferred: D47's no-net-change-is-a-no-op makes unsubscribeDep(S)+subscribeDep(S) on the SAME boundary cancel out. D115 keeps the model to ordinary unsubscribe plus a later subscribe, so same-node repeat needs a separate future design.)

Mechanism (reuses the D47 self-rewire substrate, like the *Map family; NOT an internal subscribe, D45): on activation it mints round 0's inner via ctx.rewireNext.subscribeDep; each round's inner DATA is forwarded; on the inner's COMPLETE (completeWhenDepsComplete:false + terminalAsRealInput:true) it unsubscribeDep's the finished inner and, if rounds remain, subscribeDep's a FRESH factory() inner (a distinct node → a real net change, not the no-op same-node case); after the last round it emits COMPLETE. An inner ERROR auto-forwards (errorWhenDepsError default → repeat errors). The body is SELF-CATCHING (D30) and re-supplied on every rewire. The factory MUST mint a FRESH node per call (a factory returning the same Node makes unsubscribeDep+subscribeDep a net-zero no-op → repeat wedges).

Import

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

Signature

function repeat(
	factory: () => NodeInput<S>,
	count: number,
): Operator<never, S>

Parameters

ParameterTypeDescription
factory() => NodeInput<S>factory value used by the helper.
countnumbercount value used by the helper.

Returns

A Operator<never, S> value.

Example

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

Source

packages/ts/src/graph/higher-order.ts