This repository was archived by the owner on Apr 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathtakeuntil.js
47 lines (38 loc) · 1.51 KB
/
takeuntil.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var TakeUntilObservable = (function(__super__) {
inherits(TakeUntilObservable, __super__);
function TakeUntilObservable(source, other) {
this.source = source;
this.other = isPromise(other) ? observableFromPromise(other) : other;
__super__.call(this);
}
TakeUntilObservable.prototype.subscribeCore = function(o) {
return new BinaryDisposable(
this.source.subscribe(o),
this.other.subscribe(new TakeUntilObserver(o))
);
};
return TakeUntilObservable;
}(ObservableBase));
var TakeUntilObserver = (function(__super__) {
inherits(TakeUntilObserver, __super__);
function TakeUntilObserver(o) {
this._o = o;
__super__.call(this);
}
TakeUntilObserver.prototype.next = function () {
this._o.onCompleted();
};
TakeUntilObserver.prototype.error = function (err) {
this._o.onError(err);
};
TakeUntilObserver.prototype.onCompleted = noop;
return TakeUntilObserver;
}(AbstractObserver));
/**
* Returns the values from the source observable sequence until the other observable sequence produces a value.
* @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.
* @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
*/
observableProto.takeUntil = function (other) {
return new TakeUntilObservable(this, other);
};