GeezerVison is showing github.com — Observable#window(long, java.util.concurrent.TimeUnit, long) if reached "window-max-count", the timespan not work · Issue #6651 · ReactiveX/RxJava
Observable#window(long, java.util.concurrent.TimeUnit, long) if reached "window-max-count", the timespan not work #6651Descriptionio.reactivex.Observable#window(long, java.util.concurrent.TimeUnit, long)
Observable.create((ObservableOnSubscribe<Integer>) emitter -> {
emitter.onNext(0);
emitter.onNext(1);
TimeUnit.SECONDS.sleep(1);
emitter.onNext(2);
TimeUnit.SECONDS.sleep(6);
emitter.onNext(4);
emitter.onNext(5);
})
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.window(5,TimeUnit.SECONDS, 2)
.flatMapSingle(Observable::toList)
.subscribe(list -> System.out.println("list=" + list + " time: "
+ TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - l)
+ "s"));
Like the case of above, since 7 seconds, some empty arrays are expected,and "2" will be emited when the 5 seconds,but actually not.
list=[0, 1] time: 0s
list=[2, 4] time: 7s
There is nothing after 7 seconds, it make a confuse.
As the chart https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/window6.png
it says that the timeSpan still works after winow-max-size reached. Activityakarnokd commented on Sep 12, 2019 How long did you wait for "5"? There is an overload where you can specify the time window should restart upon reaching the size limit. chxchen commented on Sep 12, 2019
How long did you wait for "5"? There is an overload where you can specify the time window should restart upon reaching the size limit.
never the "5" be passed, because createObservable does not emit a "complete" in this case of "restart" is false by default.
if restart is true, the time window will restart, that is correct. akarnokd commented on Sep 12, 2019 Thanks for the details, it is a bug in the operator. I'll post fixes shortly. chxchen commented on Sep 12, 2019 Thanks for all of your contribution! akarnokd commented on Sep 18, 2019 akarnokd commented on Sep 30, 2019
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|