1 /** PURE_IMPORTS_START tslib,_util_EmptyError,_Subscriber PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { EmptyError } from '../util/EmptyError';
4 import { Subscriber } from '../Subscriber';
5 export function throwIfEmpty(errorFactory) {
6 if (errorFactory === void 0) {
7 errorFactory = defaultErrorFactory;
9 return function (source) {
10 return source.lift(new ThrowIfEmptyOperator(errorFactory));
13 var ThrowIfEmptyOperator = /*@__PURE__*/ (function () {
14 function ThrowIfEmptyOperator(errorFactory) {
15 this.errorFactory = errorFactory;
17 ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
18 return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
20 return ThrowIfEmptyOperator;
22 var ThrowIfEmptySubscriber = /*@__PURE__*/ (function (_super) {
23 tslib_1.__extends(ThrowIfEmptySubscriber, _super);
24 function ThrowIfEmptySubscriber(destination, errorFactory) {
25 var _this = _super.call(this, destination) || this;
26 _this.errorFactory = errorFactory;
27 _this.hasValue = false;
30 ThrowIfEmptySubscriber.prototype._next = function (value) {
32 this.destination.next(value);
34 ThrowIfEmptySubscriber.prototype._complete = function () {
38 err = this.errorFactory();
43 this.destination.error(err);
46 return this.destination.complete();
49 return ThrowIfEmptySubscriber;
51 function defaultErrorFactory() {
52 return new EmptyError();
54 //# sourceMappingURL=throwIfEmpty.js.map