-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample operator: last item before termination is dropped after sampling #3657
Comments
What about when the source completes and the sampler doesn't? |
@akarnokd it would emit the last item from completed source and nothing after that, no? |
Right, the diff tricked me. I expected 3 calls to emit, 1 in sampler's onNext, 1 in sampler's onCompleted and 1 in parent's onCompleted. Besides, I can see that operator still has some issues with unsubscription and backpressure management. |
Yep, 2 calls is enough: 1 in sampler's onNext and 1 in parent's onCompleted. |
So if the sampler completes, then the value should be dropped just like now? |
It is ok in my usecase. If sampler completes before source completes it means no values are expected before completion. But if source completes before sampler does it should emit last value. However, it worth discussing. |
See #3658 that contains other fixes. |
Great! Also |
Would you like to submit a PR? |
@akarnokd I would like to. Will submit soon. |
Done #3757 |
#3757 merged. |
Hi. Recently I found that
sample
operator drops last value beforeonCompleted
event. This is behaviour is valid according to these discussions #566 and #571 and this test. It originated in Rx.NET and still exists in RxJava to be consistent across all implementations as far as I understood.But, marble diagram in documentation shows otherwise: item 5 is emitted before termination and sampled by sampler.
This behaviour is odd and unexpectable. I stumbled across it trying to resolve backpressure issue with observables where last emitted item is the most important.
So, my question is whether it can be changed? I prepared a commit with fixes and corresponding tests.
Or at least marble diagram should be changed to showcase this behaviour and it would be good to have a note about it in documentation.
Thank you.
The text was updated successfully, but these errors were encountered: