mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-13 05:55:26 +00:00
update
This commit is contained in:
50
node_modules/rxjs/_esm2015/observable/IfObservable.js
generated
vendored
Normal file
50
node_modules/rxjs/_esm2015/observable/IfObservable.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
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 class IfObservable extends Observable {
|
||||
constructor(condition, thenSource, elseSource) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.thenSource = thenSource;
|
||||
this.elseSource = elseSource;
|
||||
}
|
||||
static create(condition, thenSource, elseSource) {
|
||||
return new IfObservable(condition, thenSource, elseSource);
|
||||
}
|
||||
/** @deprecated internal use only */ _subscribe(subscriber) {
|
||||
const { condition, thenSource, elseSource } = this;
|
||||
return new IfSubscriber(subscriber, condition, thenSource, elseSource);
|
||||
}
|
||||
}
|
||||
class IfSubscriber extends OuterSubscriber {
|
||||
constructor(destination, condition, thenSource, elseSource) {
|
||||
super(destination);
|
||||
this.condition = condition;
|
||||
this.thenSource = thenSource;
|
||||
this.elseSource = elseSource;
|
||||
this.tryIf();
|
||||
}
|
||||
tryIf() {
|
||||
const { condition, thenSource, elseSource } = this;
|
||||
let result;
|
||||
try {
|
||||
result = condition();
|
||||
const source = result ? thenSource : elseSource;
|
||||
if (source) {
|
||||
this.add(subscribeToResult(this, source));
|
||||
}
|
||||
else {
|
||||
this._complete();
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this._error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=IfObservable.js.map
|
Reference in New Issue
Block a user