1 /** PURE_IMPORTS_START _ReplaySubject PURE_IMPORTS_END */
2 import { ReplaySubject } from '../ReplaySubject';
3 export function shareReplay(configOrBufferSize, windowTime, scheduler) {
5 if (configOrBufferSize && typeof configOrBufferSize === 'object') {
6 config = configOrBufferSize;
10 bufferSize: configOrBufferSize,
11 windowTime: windowTime,
16 return function (source) { return source.lift(shareReplayOperator(config)); };
18 function shareReplayOperator(_a) {
19 var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
24 var isComplete = false;
25 return function shareReplayOperation(source) {
28 if (!subject || hasError) {
30 subject = new ReplaySubject(bufferSize, windowTime, scheduler);
31 innerSub = subject.subscribe(this);
32 subscription = source.subscribe({
33 next: function (value) { subject.next(value); },
34 error: function (err) {
38 complete: function () {
40 subscription = undefined;
46 innerSub = subject.subscribe(this);
48 this.add(function () {
50 innerSub.unsubscribe();
51 if (subscription && !isComplete && useRefCount && refCount === 0) {
52 subscription.unsubscribe();
53 subscription = undefined;
59 //# sourceMappingURL=shareReplay.js.map