Skip to content
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

OnBackpressureLatest: Non-blocking version of the toBlocking().latest() operator. #2923

Merged
merged 1 commit into from
May 13, 2015

Conversation

akarnokd
Copy link
Member

This is essentially the pair of the OnBackpressureDrop. While OnBackpressureDrop emits the first value requested and then drops the rest, OnBackpressureLatest drops values but the latest and emits that when requested. One can also think of this operator as a sample with backpressure.

One mentionable property is that since it holds onto the very last value, downstream has to request at least one to receive onCompleted().

* Note that if the upstream Observable does support backpressure, this operator ignores that capability
* and doesn't propagate any backpressure requests from downstream.
* <p>
* Note that due to the nature of how backpressure requests are propagated through subscribeOn/observeOn,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence isn't clear to me. I imagine it has something to do with how request(n) generally will happen in batches so onNext emissions will happen in bursts and drop everything but the latest in between in each burst?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that the operator basically pairs requests and emission on a 1:1 basis: if one requests 5, it would behave as if one called request(1) five times and thus giving the window for dropping unawaited values.

@benjchristensen
Copy link
Member

I like this feature. Been wanting something like this for a while.

benjchristensen added a commit that referenced this pull request May 13, 2015
OnBackpressureLatest: Non-blocking version of the toBlocking().latest() operator.
@benjchristensen benjchristensen merged commit b0250bb into ReactiveX:1.x May 13, 2015
@akarnokd akarnokd deleted the OnBackpressureLatest branch May 13, 2015 21:39
@benjchristensen benjchristensen mentioned this pull request May 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants