Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / src/public-api / share

Function: share() ​

share<T>(): Operator<T, T>

Defined in: projects/libraries/streamix/src/lib/operators/share.ts:21

Shares a single subscription to the source stream between multiple consumers.

This operator multicasts the upstream iterator through an internal subject so that every subsequent consumer receives the same values without re-running the source. Because the shared subject is an Atom, a late consumer first receives the subject's current value when one exists, then continues with live emissions. This is a one-value current snapshot, not a replay history; use shareReplay() when multiple past values must be retained.

Timing caveat: values produced before the internal subject has acquired a current value are not recoverable, and only the latest current value is visible to a later consumer.

Type Parameters ​

T ​

T = any

Value type in the shared stream.

Returns ​

Operator<T, T>

An operator that can be inserted into a pipeline to share the source.

Released under the MIT License.