Skip to main content

shareObservablePipeWithMulticastReplaySource

Alternative: shareR$$$

Inlined: shareObservableWithMulticastReplaySource, shareR$$

Types

function shareObservablePipeWithMulticastReplaySource<GValue>(
options?: IShareObservableWithMulticastReplaySourceOptions<GValue>,
): IObservablePipe<GValue, GValue>

Definition

This ObservablePipe is a shortcut for:

shareObservablePipe<GValue>({
...options,
createSource: () => createMulticastReplaySource<GValue>(maxNumberOfValues),
})

See shareObservablePipe and createMulticastReplaySource.

Example

Sharing the same Observable

const subscribe = pipe$$(interval(1000), [
scan$$$<void, number>(count => (count + 1), 0),
shareR$$$<number>(),
]);

subscribe((value: number) => {
console.log('value - A:', value);
});

// note that interval(1000) is only subscribed once
subscribe((value: number) => {
console.log('value - B:', value);
});

Output:

// 1000ms
value - A: 0
value - B: 0
// 1000ms
value - A: 1
value - B: 1
...