@epikodelabs/streamix / src/public-api / shareReplay
Function: shareReplay()
shareReplay<
T>(bufferSize?):Operator<T,T>
Defined in: projects/libraries/streamix/src/lib/operators/shareReplay.ts:23
Creates a stream operator that shares a single subscription to the source stream and replays a specified number of past values to new subscribers.
This operator multicasts the source stream, ensuring that multiple downstream consumers can receive values from a single source connection. It uses an internal atom and a bounded replay buffer so that late subscribers receive the most recent values before continuing with live emissions.
This is useful for:
- Preventing redundant execution of a source stream (e.g. a network request).
- Providing a "state history" to late subscribers.
Type Parameters
T
T = any
The type of the values in the stream.
Parameters
bufferSize?
MaybePromise<number> = Infinity
The number of last values to replay to new subscribers. Defaults to Infinity. Can be a Promise that resolves to a number.
Returns
Operator<T, T>
An Operator instance that can be used in a stream's pipe method.