source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/shareReplay.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/** PURE_IMPORTS_START _ReplaySubject PURE_IMPORTS_END */
2import { ReplaySubject } from '../ReplaySubject';
3export function shareReplay(configOrBufferSize, windowTime, scheduler) {
4 var config;
5 if (configOrBufferSize && typeof configOrBufferSize === 'object') {
6 config = configOrBufferSize;
7 }
8 else {
9 config = {
10 bufferSize: configOrBufferSize,
11 windowTime: windowTime,
12 refCount: false,
13 scheduler: scheduler,
14 };
15 }
16 return function (source) { return source.lift(shareReplayOperator(config)); };
17}
18function 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;
20 var subject;
21 var refCount = 0;
22 var subscription;
23 var hasError = false;
24 var isComplete = false;
25 return function shareReplayOperation(source) {
26 refCount++;
27 var innerSub;
28 if (!subject || hasError) {
29 hasError = false;
30 subject = new ReplaySubject(bufferSize, windowTime, scheduler);
31 innerSub = subject.subscribe(this);
32 subscription = source.subscribe({
33 next: function (value) {
34 subject.next(value);
35 },
36 error: function (err) {
37 hasError = true;
38 subject.error(err);
39 },
40 complete: function () {
41 isComplete = true;
42 subscription = undefined;
43 subject.complete();
44 },
45 });
46 if (isComplete) {
47 subscription = undefined;
48 }
49 }
50 else {
51 innerSub = subject.subscribe(this);
52 }
53 this.add(function () {
54 refCount--;
55 innerSub.unsubscribe();
56 innerSub = undefined;
57 if (subscription && !isComplete && useRefCount && refCount === 0) {
58 subscription.unsubscribe();
59 subscription = undefined;
60 subject = undefined;
61 }
62 });
63 };
64}
65//# sourceMappingURL=shareReplay.js.map
Note: See TracBrowser for help on using the repository browser.