You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.4 KiB
62 lines
2.4 KiB
/** PURE_IMPORTS_START .._Observable,.._util_subscribeToResult,.._OuterSubscriber PURE_IMPORTS_END */ |
|
var __extends = (this && this.__extends) || function (d, b) { |
|
for (var p in b) |
|
if (b.hasOwnProperty(p)) |
|
d[p] = b[p]; |
|
function __() { this.constructor = d; } |
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
}; |
|
import { Observable } from '../Observable'; |
|
import { subscribeToResult } from '../util/subscribeToResult'; |
|
import { OuterSubscriber } from '../OuterSubscriber'; |
|
/** |
|
* We need this JSDoc comment for affecting ESDoc. |
|
* @extends {Ignored} |
|
* @hide true |
|
*/ |
|
export var IfObservable = /*@__PURE__*/ (/*@__PURE__*/ function (_super) { |
|
__extends(IfObservable, _super); |
|
function IfObservable(condition, thenSource, elseSource) { |
|
_super.call(this); |
|
this.condition = condition; |
|
this.thenSource = thenSource; |
|
this.elseSource = elseSource; |
|
} |
|
IfObservable.create = function (condition, thenSource, elseSource) { |
|
return new IfObservable(condition, thenSource, elseSource); |
|
}; |
|
/** @deprecated internal use only */ IfObservable.prototype._subscribe = function (subscriber) { |
|
var _a = this, condition = _a.condition, thenSource = _a.thenSource, elseSource = _a.elseSource; |
|
return new IfSubscriber(subscriber, condition, thenSource, elseSource); |
|
}; |
|
return IfObservable; |
|
}(Observable)); |
|
var IfSubscriber = /*@__PURE__*/ (/*@__PURE__*/ function (_super) { |
|
__extends(IfSubscriber, _super); |
|
function IfSubscriber(destination, condition, thenSource, elseSource) { |
|
_super.call(this, destination); |
|
this.condition = condition; |
|
this.thenSource = thenSource; |
|
this.elseSource = elseSource; |
|
this.tryIf(); |
|
} |
|
IfSubscriber.prototype.tryIf = function () { |
|
var _a = this, condition = _a.condition, thenSource = _a.thenSource, elseSource = _a.elseSource; |
|
var result; |
|
try { |
|
result = condition(); |
|
var source = result ? thenSource : elseSource; |
|
if (source) { |
|
this.add(subscribeToResult(this, source)); |
|
} |
|
else { |
|
this._complete(); |
|
} |
|
} |
|
catch (err) { |
|
this._error(err); |
|
} |
|
}; |
|
return IfSubscriber; |
|
}(OuterSubscriber)); |
|
//# sourceMappingURL=IfObservable.js.map
|
|
|