| 1 |
import { Subscriber } from '../Subscriber'; |
| 2 |
export function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) { |
| 3 |
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize); |
| 4 |
} |
| 5 |
export class OperatorSubscriber extends Subscriber { |
| 6 |
constructor(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) { |
| 7 |
super(destination); |
| 8 |
this.onFinalize = onFinalize; |
| 9 |
this.shouldUnsubscribe = shouldUnsubscribe; |
| 10 |
this._next = onNext |
| 11 |
? function (value) { |
| 12 |
try { |
| 13 |
onNext(value); |
| 14 |
} |
| 15 |
catch (err) { |
| 16 |
destination.error(err); |
| 17 |
} |
| 18 |
} |
| 19 |
: super._next; |
| 20 |
this._error = onError |
| 21 |
? function (err) { |
| 22 |
try { |
| 23 |
onError(err); |
| 24 |
} |
| 25 |
catch (err) { |
| 26 |
destination.error(err); |
| 27 |
} |
| 28 |
finally { |
| 29 |
this.unsubscribe(); |
| 30 |
} |
| 31 |
} |
| 32 |
: super._error; |
| 33 |
this._complete = onComplete |
| 34 |
? function () { |
| 35 |
try { |
| 36 |
onComplete(); |
| 37 |
} |
| 38 |
catch (err) { |
| 39 |
destination.error(err); |
| 40 |
} |
| 41 |
finally { |
| 42 |
this.unsubscribe(); |
| 43 |
} |
| 44 |
} |
| 45 |
: super._complete; |
| 46 |
} |
| 47 |
unsubscribe() { |
| 48 |
var _a; |
| 49 |
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) { |
| 50 |
const { closed } = this; |
| 51 |
super.unsubscribe(); |
| 52 |
!closed && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this)); |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
//# sourceMappingURL=OperatorSubscriber.js.map |