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