source: trip-planner-front/node_modules/rxjs/internal/operators/refCount.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.6 KB
Line 
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 }
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var Subscriber_1 = require("../Subscriber");
17function refCount() {
18 return function refCountOperatorFunction(source) {
19 return source.lift(new RefCountOperator(source));
20 };
21}
22exports.refCount = refCount;
23var RefCountOperator = (function () {
24 function RefCountOperator(connectable) {
25 this.connectable = connectable;
26 }
27 RefCountOperator.prototype.call = function (subscriber, source) {
28 var connectable = this.connectable;
29 connectable._refCount++;
30 var refCounter = new RefCountSubscriber(subscriber, connectable);
31 var subscription = source.subscribe(refCounter);
32 if (!refCounter.closed) {
33 refCounter.connection = connectable.connect();
34 }
35 return subscription;
36 };
37 return RefCountOperator;
38}());
39var RefCountSubscriber = (function (_super) {
40 __extends(RefCountSubscriber, _super);
41 function RefCountSubscriber(destination, connectable) {
42 var _this = _super.call(this, destination) || this;
43 _this.connectable = connectable;
44 return _this;
45 }
46 RefCountSubscriber.prototype._unsubscribe = function () {
47 var connectable = this.connectable;
48 if (!connectable) {
49 this.connection = null;
50 return;
51 }
52 this.connectable = null;
53 var refCount = connectable._refCount;
54 if (refCount <= 0) {
55 this.connection = null;
56 return;
57 }
58 connectable._refCount = refCount - 1;
59 if (refCount > 1) {
60 this.connection = null;
61 return;
62 }
63 var connection = this.connection;
64 var sharedConnection = connectable._connection;
65 this.connection = null;
66 if (sharedConnection && (!connection || sharedConnection === connection)) {
67 sharedConnection.unsubscribe();
68 }
69 };
70 return RefCountSubscriber;
71}(Subscriber_1.Subscriber));
72//# sourceMappingURL=refCount.js.map
Note: See TracBrowser for help on using the repository browser.