1 import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
2 export interface ShareReplayConfig {
6 scheduler?: SchedulerLike;
9 * Share source and replay specified number of emissions on subscription.
11 * This operator is a specialization of `replay` that connects to a source observable
12 * and multicasts through a `ReplaySubject` constructed with the specified arguments.
13 * A successfully completed source will stay cached in the `shareReplayed observable` forever,
14 * but an errored source can be retried.
16 * ## Why use shareReplay?
17 * You generally want to use `shareReplay` when you have side-effects or taxing computations
18 * that you do not wish to be executed amongst multiple subscribers.
19 * It may also be valuable in situations where you know you will have late subscribers to
20 * a stream that need access to previously emitted values.
21 * This ability to replay values on subscription is what differentiates {@link share} and `shareReplay`.
23 * ![](shareReplay.png)
27 * import { interval } from 'rxjs';
28 * import { shareReplay, take } from 'rxjs/operators';
30 * const obs$ = interval(1000);
31 * const shared$ = obs$.pipe(
35 * shared$.subscribe(x => console.log('source A: ', x));
36 * shared$.subscribe(y => console.log('source B: ', y));
40 * @see {@link publish}
42 * @see {@link publishReplay}
44 * @param {Number} [bufferSize=Number.POSITIVE_INFINITY] Maximum element count of the replay buffer.
45 * @param {Number} [windowTime=Number.POSITIVE_INFINITY] Maximum time length of the replay buffer in milliseconds.
46 * @param {Scheduler} [scheduler] Scheduler where connected observers within the selector function
48 * @return {Observable} An observable sequence that contains the elements of a sequence produced
49 * by multicasting the source sequence within a selector function.
53 export declare function shareReplay<T>(config: ShareReplayConfig): MonoTypeOperatorFunction<T>;
54 export declare function shareReplay<T>(bufferSize?: number, windowTime?: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;