Skip to content

Sample operator: last item before termination is dropped after sampling #3657

Closed
@kboyarshinov

Description

@kboyarshinov

Hi. Recently I found that sample operator drops last value before onCompleted 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.
sample_marble

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions