1 /** PURE_IMPORTS_START tslib,_Subscriber,_util_noop,_util_isFunction PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { Subscriber } from '../Subscriber';
4 import { noop } from '../util/noop';
5 import { isFunction } from '../util/isFunction';
6 export function tap(nextOrObserver, error, complete) {
7 return function tapOperatorFunction(source) {
8 return source.lift(new DoOperator(nextOrObserver, error, complete));
11 var DoOperator = /*@__PURE__*/ (function () {
12 function DoOperator(nextOrObserver, error, complete) {
13 this.nextOrObserver = nextOrObserver;
15 this.complete = complete;
17 DoOperator.prototype.call = function (subscriber, source) {
18 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
22 var TapSubscriber = /*@__PURE__*/ (function (_super) {
23 tslib_1.__extends(TapSubscriber, _super);
24 function TapSubscriber(destination, observerOrNext, error, complete) {
25 var _this = _super.call(this, destination) || this;
26 _this._tapNext = noop;
27 _this._tapError = noop;
28 _this._tapComplete = noop;
29 _this._tapError = error || noop;
30 _this._tapComplete = complete || noop;
31 if (isFunction(observerOrNext)) {
32 _this._context = _this;
33 _this._tapNext = observerOrNext;
35 else if (observerOrNext) {
36 _this._context = observerOrNext;
37 _this._tapNext = observerOrNext.next || noop;
38 _this._tapError = observerOrNext.error || noop;
39 _this._tapComplete = observerOrNext.complete || noop;
43 TapSubscriber.prototype._next = function (value) {
45 this._tapNext.call(this._context, value);
48 this.destination.error(err);
51 this.destination.next(value);
53 TapSubscriber.prototype._error = function (err) {
55 this._tapError.call(this._context, err);
58 this.destination.error(err);
61 this.destination.error(err);
63 TapSubscriber.prototype._complete = function () {
65 this._tapComplete.call(this._context);
68 this.destination.error(err);
71 return this.destination.complete();
75 //# sourceMappingURL=tap.js.map