Skip to main content

shareObservablePipeWithMulticastReplayLastSource

Alternative: shareRL$$$

Inlined: shareObservableWithMulticastReplayLastSource, shareRL$$

Types

function shareObservablePipeWithMulticastReplayLastSource<GValue>(
options?: IShareObservableWithMulticastReplayLastSourceOptions<GValue>,
): IObservablePipe<GValue, GValue>

Definition

This ObservablePipe is a shortcut for:

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

See shareObservablePipe and createMulticastReplayLastSource.

Example

Sharing the same Observable

const subscribe = pipe$$(interval(1000), [
scan$$$<void, number>(count => (count + 1), 0),
shareRL$$$<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
...