Skip to content

Observable#window(long, java.util.concurrent.TimeUnit, long) if reached "window-max-count", the timespan not work #6651

Closed
@chxchen

Description

@chxchen

io.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions