This repository has been 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
/
skipuntil.js
81 lines (64 loc) · 2.62 KB
/
skipuntil.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var SkipUntilObservable = (function(__super__) {
inherits(SkipUntilObservable, __super__);
function SkipUntilObservable(source, other) {
this._s = source;
this._o = isPromise(other) ? observableFromPromise(other) : other;
this._open = false;
__super__.call(this);
}
SkipUntilObservable.prototype.subscribeCore = function(o) {
var leftSubscription = new SingleAssignmentDisposable();
leftSubscription.setDisposable(this._s.subscribe(new SkipUntilSourceObserver(o, this)));
isPromise(this._o) && (this._o = observableFromPromise(this._o));
var rightSubscription = new SingleAssignmentDisposable();
rightSubscription.setDisposable(this._o.subscribe(new SkipUntilOtherObserver(o, this, rightSubscription)));
return new BinaryDisposable(leftSubscription, rightSubscription);
};
return SkipUntilObservable;
}(ObservableBase));
var SkipUntilSourceObserver = (function(__super__) {
inherits(SkipUntilSourceObserver, __super__);
function SkipUntilSourceObserver(o, p) {
this._o = o;
this._p = p;
__super__.call(this);
}
SkipUntilSourceObserver.prototype.next = function (x) {
this._p._open && this._o.onNext(x);
};
SkipUntilSourceObserver.prototype.error = function (err) {
this._o.onError(err);
};
SkipUntilSourceObserver.prototype.onCompleted = function () {
this._p._open && this._o.onCompleted();
};
return SkipUntilSourceObserver;
}(AbstractObserver));
var SkipUntilOtherObserver = (function(__super__) {
inherits(SkipUntilOtherObserver, __super__);
function SkipUntilOtherObserver(o, p, r) {
this._o = o;
this._p = p;
this._r = r;
__super__.call(this);
}
SkipUntilOtherObserver.prototype.next = function () {
this._p._open = true;
this._r.dispose();
};
SkipUntilOtherObserver.prototype.error = function (err) {
this._o.onError(err);
};
SkipUntilOtherObserver.prototype.onCompleted = function () {
this._r.dispose();
};
return SkipUntilOtherObserver;
}(AbstractObserver));
/**
* Returns the values from the source observable sequence only after the other observable sequence produces a value.
* @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.
* @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
*/
observableProto.skipUntil = function (other) {
return new SkipUntilObservable(this, other);
};