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

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

initial commit

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