1 import { Subscriber } from '../Subscriber';
2 import { noop } from '../util/noop';
3 import { isFunction } from '../util/isFunction';
4 export function tap(nextOrObserver, error, complete) {
5 return function tapOperatorFunction(source) {
6 return source.lift(new DoOperator(nextOrObserver, error, complete));
10 constructor(nextOrObserver, error, complete) {
11 this.nextOrObserver = nextOrObserver;
13 this.complete = complete;
15 call(subscriber, source) {
16 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
19 class TapSubscriber extends Subscriber {
20 constructor(destination, observerOrNext, error, complete) {
23 this._tapError = noop;
24 this._tapComplete = noop;
25 this._tapError = error || noop;
26 this._tapComplete = complete || noop;
27 if (isFunction(observerOrNext)) {
29 this._tapNext = observerOrNext;
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;
40 this._tapNext.call(this._context, value);
43 this.destination.error(err);
46 this.destination.next(value);
50 this._tapError.call(this._context, err);
53 this.destination.error(err);
56 this.destination.error(err);
60 this._tapComplete.call(this._context);
63 this.destination.error(err);
66 return this.destination.complete();
69 //# sourceMappingURL=tap.js.map