source: trip-planner-front/node_modules/rxjs/_esm2015/internal/operators/tap.js@ 6a3a178

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

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1import { Subscriber } from '../Subscriber';
2import { noop } from '../util/noop';
3import { isFunction } from '../util/isFunction';
4export function tap(nextOrObserver, error, complete) {
5 return function tapOperatorFunction(source) {
6 return source.lift(new DoOperator(nextOrObserver, error, complete));
7 };
8}
9class DoOperator {
10 constructor(nextOrObserver, error, complete) {
11 this.nextOrObserver = nextOrObserver;
12 this.error = error;
13 this.complete = complete;
14 }
15 call(subscriber, source) {
16 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
17 }
18}
19class TapSubscriber extends Subscriber {
20 constructor(destination, observerOrNext, error, complete) {
21 super(destination);
22 this._tapNext = noop;
23 this._tapError = noop;
24 this._tapComplete = noop;
25 this._tapError = error || noop;
26 this._tapComplete = complete || noop;
27 if (isFunction(observerOrNext)) {
28 this._context = this;
29 this._tapNext = observerOrNext;
30 }
31 else if (observerOrNext) {
32 this._context = observerOrNext;
33 this._tapNext = observerOrNext.next || noop;
34 this._tapError = observerOrNext.error || noop;
35 this._tapComplete = observerOrNext.complete || noop;
36 }
37 }
38 _next(value) {
39 try {
40 this._tapNext.call(this._context, value);
41 }
42 catch (err) {
43 this.destination.error(err);
44 return;
45 }
46 this.destination.next(value);
47 }
48 _error(err) {
49 try {
50 this._tapError.call(this._context, err);
51 }
52 catch (err) {
53 this.destination.error(err);
54 return;
55 }
56 this.destination.error(err);
57 }
58 _complete() {
59 try {
60 this._tapComplete.call(this._context);
61 }
62 catch (err) {
63 this.destination.error(err);
64 return;
65 }
66 return this.destination.complete();
67 }
68}
69//# sourceMappingURL=tap.js.map
Note: See TracBrowser for help on using the repository browser.