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
/
skipuntilwithtime.js
56 lines (47 loc) · 2.28 KB
/
skipuntilwithtime.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
var SkipUntilWithTimeObservable = (function (__super__) {
inherits(SkipUntilWithTimeObservable, __super__);
function SkipUntilWithTimeObservable(source, startTime, scheduler) {
this.source = source;
this._st = startTime;
this._s = scheduler;
__super__.call(this);
}
function scheduleMethod(s, state) {
state._open = true;
}
SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) {
this._open = false;
return new BinaryDisposable(
this._s.scheduleFuture(this, this._st, scheduleMethod),
this.source.subscribe(new SkipUntilWithTimeObserver(o, this))
);
};
return SkipUntilWithTimeObservable;
}(ObservableBase));
var SkipUntilWithTimeObserver = (function (__super__) {
inherits(SkipUntilWithTimeObserver, __super__);
function SkipUntilWithTimeObserver(o, p) {
this._o = o;
this._p = p;
__super__.call(this);
}
SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); };
SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };
SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); };
return SkipUntilWithTimeObserver;
}(AbstractObserver));
/**
* Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
* Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
*
* @examples
* 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);
* 2 - res = source.skipUntilWithTime(5000, [scheduler]);
* @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
* @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
* @returns {Observable} An observable sequence with the elements skipped until the specified start time.
*/
observableProto.skipUntilWithTime = function (startTime, scheduler) {
isScheduler(scheduler) || (scheduler = defaultScheduler);
return new SkipUntilWithTimeObservable(this, startTime, scheduler);
};