source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/audit.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.5 KB
Line 
1/** PURE_IMPORTS_START tslib,_innerSubscribe PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
4export function audit(durationSelector) {
5 return function auditOperatorFunction(source) {
6 return source.lift(new AuditOperator(durationSelector));
7 };
8}
9var AuditOperator = /*@__PURE__*/ (function () {
10 function AuditOperator(durationSelector) {
11 this.durationSelector = durationSelector;
12 }
13 AuditOperator.prototype.call = function (subscriber, source) {
14 return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
15 };
16 return AuditOperator;
17}());
18var AuditSubscriber = /*@__PURE__*/ (function (_super) {
19 tslib_1.__extends(AuditSubscriber, _super);
20 function AuditSubscriber(destination, durationSelector) {
21 var _this = _super.call(this, destination) || this;
22 _this.durationSelector = durationSelector;
23 _this.hasValue = false;
24 return _this;
25 }
26 AuditSubscriber.prototype._next = function (value) {
27 this.value = value;
28 this.hasValue = true;
29 if (!this.throttled) {
30 var duration = void 0;
31 try {
32 var durationSelector = this.durationSelector;
33 duration = durationSelector(value);
34 }
35 catch (err) {
36 return this.destination.error(err);
37 }
38 var innerSubscription = innerSubscribe(duration, new SimpleInnerSubscriber(this));
39 if (!innerSubscription || innerSubscription.closed) {
40 this.clearThrottle();
41 }
42 else {
43 this.add(this.throttled = innerSubscription);
44 }
45 }
46 };
47 AuditSubscriber.prototype.clearThrottle = function () {
48 var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
49 if (throttled) {
50 this.remove(throttled);
51 this.throttled = undefined;
52 throttled.unsubscribe();
53 }
54 if (hasValue) {
55 this.value = undefined;
56 this.hasValue = false;
57 this.destination.next(value);
58 }
59 };
60 AuditSubscriber.prototype.notifyNext = function () {
61 this.clearThrottle();
62 };
63 AuditSubscriber.prototype.notifyComplete = function () {
64 this.clearThrottle();
65 };
66 return AuditSubscriber;
67}(SimpleOuterSubscriber));
68//# sourceMappingURL=audit.js.map
Note: See TracBrowser for help on using the repository browser.