Debian Codegraph @

node/rxjs/dist/esm5/internal/operators/tap.js

raw
1 import { isFunction } from '../util/isFunction';
2 import { operate } from '../util/lift';
3 import { createOperatorSubscriber } from './OperatorSubscriber';
4 import { identity } from '../util/identity';
5 export function tap(observerOrNext, error, complete) {
6 var tapObserver = isFunction(observerOrNext) || error || complete
7 ?
8 { next: observerOrNext, error: error, complete: complete }
9 : observerOrNext;
10 return tapObserver
11 ? operate(function (source, subscriber) {
12 var _a;
13 (_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
14 var isUnsub = true;
15 source.subscribe(createOperatorSubscriber(subscriber, function (value) {
16 var _a;
17 (_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
18 subscriber.next(value);
19 }, function () {
20 var _a;
21 isUnsub = false;
22 (_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
23 subscriber.complete();
24 }, function (err) {
25 var _a;
26 isUnsub = false;
27 (_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
28 subscriber.error(err);
29 }, function () {
30 var _a, _b;
31 if (isUnsub) {
32 (_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
33 }
34 (_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
35 }));
36 })
37 :
38 identity;
39 }
40 //# sourceMappingURL=tap.js.map