diff --git a/compat/operator/shareReplay.ts b/compat/operator/shareReplay.ts index c5a0ebf455..33cd702797 100644 --- a/compat/operator/shareReplay.ts +++ b/compat/operator/shareReplay.ts @@ -1,11 +1,18 @@ import { Observable, SchedulerLike } from 'rxjs'; import { shareReplay as higherOrder } from 'rxjs/operators'; +import { ShareReplayConfig } from 'rxjs/internal-compatibility'; /** * @method shareReplay * @owner Observable */ -export function shareReplay(this: Observable, bufferSize?: number, windowTime?: number, scheduler?: SchedulerLike): +export function shareReplay(this: Observable, config: ShareReplayConfig): Observable; +/** @deprecated Use config parameter */ +export function shareReplay(this: Observable, bufferSize?: number, windowTime?: number, scheduler?: SchedulerLike): Observable; +export function shareReplay(this: Observable, configOrBufferSize?: ShareReplayConfig | number, windowTime?: number, scheduler?: SchedulerLike): Observable { - return higherOrder(bufferSize, windowTime, scheduler)(this) as Observable; + if (configOrBufferSize && typeof configOrBufferSize === 'object') { + return higherOrder(configOrBufferSize as ShareReplayConfig)(this) as Observable; + } + return higherOrder(configOrBufferSize as number | undefined, windowTime, scheduler)(this) as Observable; } diff --git a/src/internal-compatibility/index.ts b/src/internal-compatibility/index.ts index a8998475a0..c7b0058207 100644 --- a/src/internal-compatibility/index.ts +++ b/src/internal-compatibility/index.ts @@ -23,6 +23,7 @@ export { SubscribeOnObservable } from '../internal/observable/SubscribeOnObserva export { Timestamp } from '../internal/operators/timestamp'; export { TimeInterval } from '../internal/operators/timeInterval'; export { GroupedObservable } from '../internal/operators/groupBy'; +export { ShareReplayConfig } from '../internal/operators/shareReplay'; export { ThrottleConfig, defaultThrottleConfig } from '../internal/operators/throttle'; export { rxSubscriber } from '../internal/symbol/rxSubscriber';