2.x: confused of method takeLast(long,TimeUnit)
See original GitHub issueI’m a little confused about takeLast(long, TimeUnit). When executing the following code, each time the output order is supposed to be N digits in the last time window, but in fact the output results are inconsistent with the ideal state.
Code
public static void main(String[] args) {
ArrayList<Integer> ints = new ArrayList<>();
for (int i = 0; i < 100; i++) {
ints.add(i);
}
Observable.fromIterable(ints)
.takeLast(1,TimeUnit.NANOSECONDS)
.subscribe(longs->{
System.out.println(longs);
});
try {
Thread.sleep(100000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Result
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
RxJava's takeLast method does not act as JavaDoc described
First of all, I guess your assumption would be 3 and 4 instead of 2 and 3 , given that there is also...
Read more >TakeLast operator - ReactiveX
TakeLast. emit only the final n items emitted by an Observable. 1. 2 ... RxGroovy takeLast takeLastBuffer. takeLast ... RxJava 1․x takeLast takeLastBuffer....
Read more >Enumerable.TakeLast<TSource>(IEnumerable<TSource ...
If count is not a positive number, this method returns an empty enumerable collection. Applies to. Product, Versions .NET, Core 2.0, Core 2.1,...
Read more >takeLast - RxJS
takeLast results in an observable that will hold values up to count values in memory, until the source completes. It then pushes all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Because onComplete can happen much later than the previous onNext, thus that value is now out of the time window.
@akarnokd Hello! I would like to know that the takeLast() method is to get the data of the last window that was sent. We already got the data of the last window in the OnNext() method, so why do we have to make another time difference judgment in the onComplete() method