Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit 26e340e

Browse files
Fixing skipwhile and skipuntilwithtime
1 parent e462179 commit 26e340e

35 files changed

+672
-246
lines changed

dist/rx.all.compat.js

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5661,6 +5661,46 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
56615661
if (count < 0) { throw new ArgumentOutOfRangeError(); }
56625662
return new SkipObservable(this, count);
56635663
};
5664+
var SkipWhileObservable = (function (__super__) {
5665+
inherits(SkipWhileObservable, __super__);
5666+
function SkipWhileObservable(source, fn) {
5667+
this.source = source;
5668+
this._fn = fn;
5669+
__super__.call(this);
5670+
}
5671+
5672+
SkipWhileObservable.prototype.subscribeCore = function (o) {
5673+
return this.source.subscribe(new SkipWhileObserver(o, this));
5674+
};
5675+
5676+
return SkipWhileObservable;
5677+
}(ObservableBase));
5678+
5679+
var SkipWhileObserver = (function (__super__) {
5680+
inherits(SkipWhileObserver, __super__);
5681+
5682+
function SkipWhileObserver(o, p) {
5683+
this._o = o;
5684+
this._p = p;
5685+
this._i = 0;
5686+
this._r = false;
5687+
__super__.call(this);
5688+
}
5689+
5690+
SkipWhileObserver.prototype.next = function (x) {
5691+
if (!this._r) {
5692+
var res = tryCatch(this._p._fn)(x, this._i++, this._p);
5693+
if (res === errorObj) { return this._o.onError(res.e); }
5694+
this._r = !res;
5695+
}
5696+
this._r && this._o.onNext(x);
5697+
};
5698+
SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); };
5699+
SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); };
5700+
5701+
return SkipWhileObserver;
5702+
}(AbstractObserver));
5703+
56645704
/**
56655705
* Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
56665706
* The element's index is used in the logic of the predicate function.
@@ -5672,22 +5712,8 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
56725712
* @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
56735713
*/
56745714
observableProto.skipWhile = function (predicate, thisArg) {
5675-
var source = this,
5676-
callback = bindCallback(predicate, thisArg, 3);
5677-
return new AnonymousObservable(function (o) {
5678-
var i = 0, running = false;
5679-
return source.subscribe(function (x) {
5680-
if (!running) {
5681-
try {
5682-
running = !callback(x, i++, source);
5683-
} catch (e) {
5684-
o.onError(e);
5685-
return;
5686-
}
5687-
}
5688-
running && o.onNext(x);
5689-
}, function (e) { o.onError(e); }, function () { o.onCompleted(); });
5690-
}, source);
5715+
var fn = bindCallback(predicate, thisArg, 3);
5716+
return new SkipWhileObservable(this, fn);
56915717
};
56925718

56935719
var TakeObservable = (function(__super__) {
@@ -10708,6 +10734,47 @@ Observable.fromNodeCallback = function (fn, ctx, selector) {
1070810734
}, source);
1070910735
};
1071010736

10737+
var SkipUntilWithTimeObservable = (function (__super__) {
10738+
inherits(SkipUntilWithTimeObservable, __super__);
10739+
function SkipUntilWithTimeObservable(source, startTime, scheduler) {
10740+
this.source = source;
10741+
this._st = startTime;
10742+
this._s = scheduler;
10743+
__super__.call(this);
10744+
}
10745+
10746+
function scheduleMethod(s, state) {
10747+
state._open = true;
10748+
}
10749+
10750+
SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) {
10751+
this._open = false;
10752+
return new BinaryDisposable(
10753+
this._s.scheduleFuture(this, this._st, scheduleMethod),
10754+
this.source.subscribe(new SkipUntilWithTimeObserver(o, this))
10755+
);
10756+
};
10757+
10758+
return SkipUntilWithTimeObservable;
10759+
}(ObservableBase));
10760+
10761+
var SkipUntilWithTimeObserver = (function (__super__) {
10762+
inherits(SkipUntilWithTimeObserver, __super__);
10763+
10764+
function SkipUntilWithTimeObserver(o, p) {
10765+
this._o = o;
10766+
this._p = p;
10767+
__super__.call(this);
10768+
}
10769+
10770+
SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); };
10771+
SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };
10772+
SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); };
10773+
10774+
return SkipUntilWithTimeObserver;
10775+
}(AbstractObserver));
10776+
10777+
1071110778
/**
1071210779
* Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
1071310780
* Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
@@ -10721,16 +10788,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) {
1072110788
*/
1072210789
observableProto.skipUntilWithTime = function (startTime, scheduler) {
1072310790
isScheduler(scheduler) || (scheduler = defaultScheduler);
10724-
var source = this;
10725-
return new AnonymousObservable(function (o) {
10726-
var open = false;
10727-
10728-
return new BinaryDisposable(
10729-
scheduler.scheduleFuture(null, startTime, function () { open = true; }),
10730-
source.subscribe(
10731-
function (x) { open && o.onNext(x); },
10732-
function (e) { o.onError(e); }, function () { o.onCompleted(); }));
10733-
}, source);
10791+
return new SkipUntilWithTimeObservable(this, startTime, scheduler);
1073410792
};
1073510793

1073610794
/**

dist/rx.all.compat.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.compat.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.js

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5523,6 +5523,46 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
55235523
if (count < 0) { throw new ArgumentOutOfRangeError(); }
55245524
return new SkipObservable(this, count);
55255525
};
5526+
var SkipWhileObservable = (function (__super__) {
5527+
inherits(SkipWhileObservable, __super__);
5528+
function SkipWhileObservable(source, fn) {
5529+
this.source = source;
5530+
this._fn = fn;
5531+
__super__.call(this);
5532+
}
5533+
5534+
SkipWhileObservable.prototype.subscribeCore = function (o) {
5535+
return this.source.subscribe(new SkipWhileObserver(o, this));
5536+
};
5537+
5538+
return SkipWhileObservable;
5539+
}(ObservableBase));
5540+
5541+
var SkipWhileObserver = (function (__super__) {
5542+
inherits(SkipWhileObserver, __super__);
5543+
5544+
function SkipWhileObserver(o, p) {
5545+
this._o = o;
5546+
this._p = p;
5547+
this._i = 0;
5548+
this._r = false;
5549+
__super__.call(this);
5550+
}
5551+
5552+
SkipWhileObserver.prototype.next = function (x) {
5553+
if (!this._r) {
5554+
var res = tryCatch(this._p._fn)(x, this._i++, this._p);
5555+
if (res === errorObj) { return this._o.onError(res.e); }
5556+
this._r = !res;
5557+
}
5558+
this._r && this._o.onNext(x);
5559+
};
5560+
SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); };
5561+
SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); };
5562+
5563+
return SkipWhileObserver;
5564+
}(AbstractObserver));
5565+
55265566
/**
55275567
* Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
55285568
* The element's index is used in the logic of the predicate function.
@@ -5534,22 +5574,8 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
55345574
* @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
55355575
*/
55365576
observableProto.skipWhile = function (predicate, thisArg) {
5537-
var source = this,
5538-
callback = bindCallback(predicate, thisArg, 3);
5539-
return new AnonymousObservable(function (o) {
5540-
var i = 0, running = false;
5541-
return source.subscribe(function (x) {
5542-
if (!running) {
5543-
try {
5544-
running = !callback(x, i++, source);
5545-
} catch (e) {
5546-
o.onError(e);
5547-
return;
5548-
}
5549-
}
5550-
running && o.onNext(x);
5551-
}, function (e) { o.onError(e); }, function () { o.onCompleted(); });
5552-
}, source);
5577+
var fn = bindCallback(predicate, thisArg, 3);
5578+
return new SkipWhileObservable(this, fn);
55535579
};
55545580

55555581
var TakeObservable = (function(__super__) {
@@ -10477,6 +10503,47 @@ Observable.fromNodeCallback = function (fn, ctx, selector) {
1047710503
}, source);
1047810504
};
1047910505

10506+
var SkipUntilWithTimeObservable = (function (__super__) {
10507+
inherits(SkipUntilWithTimeObservable, __super__);
10508+
function SkipUntilWithTimeObservable(source, startTime, scheduler) {
10509+
this.source = source;
10510+
this._st = startTime;
10511+
this._s = scheduler;
10512+
__super__.call(this);
10513+
}
10514+
10515+
function scheduleMethod(s, state) {
10516+
state._open = true;
10517+
}
10518+
10519+
SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) {
10520+
this._open = false;
10521+
return new BinaryDisposable(
10522+
this._s.scheduleFuture(this, this._st, scheduleMethod),
10523+
this.source.subscribe(new SkipUntilWithTimeObserver(o, this))
10524+
);
10525+
};
10526+
10527+
return SkipUntilWithTimeObservable;
10528+
}(ObservableBase));
10529+
10530+
var SkipUntilWithTimeObserver = (function (__super__) {
10531+
inherits(SkipUntilWithTimeObserver, __super__);
10532+
10533+
function SkipUntilWithTimeObserver(o, p) {
10534+
this._o = o;
10535+
this._p = p;
10536+
__super__.call(this);
10537+
}
10538+
10539+
SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); };
10540+
SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };
10541+
SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); };
10542+
10543+
return SkipUntilWithTimeObserver;
10544+
}(AbstractObserver));
10545+
10546+
1048010547
/**
1048110548
* Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
1048210549
* Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
@@ -10490,16 +10557,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) {
1049010557
*/
1049110558
observableProto.skipUntilWithTime = function (startTime, scheduler) {
1049210559
isScheduler(scheduler) || (scheduler = defaultScheduler);
10493-
var source = this;
10494-
return new AnonymousObservable(function (o) {
10495-
var open = false;
10496-
10497-
return new BinaryDisposable(
10498-
scheduler.scheduleFuture(null, startTime, function () { open = true; }),
10499-
source.subscribe(
10500-
function (x) { open && o.onNext(x); },
10501-
function (e) { o.onError(e); }, function () { o.onCompleted(); }));
10502-
}, source);
10560+
return new SkipUntilWithTimeObservable(this, startTime, scheduler);
1050310561
};
1050410562

1050510563
/**

dist/rx.all.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.compat.js

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5559,6 +5559,46 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
55595559
if (count < 0) { throw new ArgumentOutOfRangeError(); }
55605560
return new SkipObservable(this, count);
55615561
};
5562+
var SkipWhileObservable = (function (__super__) {
5563+
inherits(SkipWhileObservable, __super__);
5564+
function SkipWhileObservable(source, fn) {
5565+
this.source = source;
5566+
this._fn = fn;
5567+
__super__.call(this);
5568+
}
5569+
5570+
SkipWhileObservable.prototype.subscribeCore = function (o) {
5571+
return this.source.subscribe(new SkipWhileObserver(o, this));
5572+
};
5573+
5574+
return SkipWhileObservable;
5575+
}(ObservableBase));
5576+
5577+
var SkipWhileObserver = (function (__super__) {
5578+
inherits(SkipWhileObserver, __super__);
5579+
5580+
function SkipWhileObserver(o, p) {
5581+
this._o = o;
5582+
this._p = p;
5583+
this._i = 0;
5584+
this._r = false;
5585+
__super__.call(this);
5586+
}
5587+
5588+
SkipWhileObserver.prototype.next = function (x) {
5589+
if (!this._r) {
5590+
var res = tryCatch(this._p._fn)(x, this._i++, this._p);
5591+
if (res === errorObj) { return this._o.onError(res.e); }
5592+
this._r = !res;
5593+
}
5594+
this._r && this._o.onNext(x);
5595+
};
5596+
SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); };
5597+
SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); };
5598+
5599+
return SkipWhileObserver;
5600+
}(AbstractObserver));
5601+
55625602
/**
55635603
* Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
55645604
* The element's index is used in the logic of the predicate function.
@@ -5570,22 +5610,8 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
55705610
* @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
55715611
*/
55725612
observableProto.skipWhile = function (predicate, thisArg) {
5573-
var source = this,
5574-
callback = bindCallback(predicate, thisArg, 3);
5575-
return new AnonymousObservable(function (o) {
5576-
var i = 0, running = false;
5577-
return source.subscribe(function (x) {
5578-
if (!running) {
5579-
try {
5580-
running = !callback(x, i++, source);
5581-
} catch (e) {
5582-
o.onError(e);
5583-
return;
5584-
}
5585-
}
5586-
running && o.onNext(x);
5587-
}, function (e) { o.onError(e); }, function () { o.onCompleted(); });
5588-
}, source);
5613+
var fn = bindCallback(predicate, thisArg, 3);
5614+
return new SkipWhileObservable(this, fn);
55895615
};
55905616

55915617
var TakeObservable = (function(__super__) {

dist/rx.compat.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.compat.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)