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

Operation Sample with another Observable #566

Closed
wants to merge 1 commit into from

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Dec 5, 2013

Issue #74

Added missing Observable.sample(Observable<U> sampler).

@cloudbees-pull-request-builder

RxJava-pull-requests #495 SUCCESS
This pull request looks good

@benjchristensen
Copy link
Member

Note: if the sampler completes before this completes, no onCompleted event is emitted (in par with Rx.NET behavior).

That seems rather odd. It could potentially leave something dangling forever.

@akarnokd
Copy link
Member Author

akarnokd commented Dec 5, 2013

I don't know the reason for this behavior in Rx.NET, but it isn't the first instance (i.e., SkipUntil). Maybe the intention was to sample both the onNext and onCompleted; if no more sampler, no more samples of onNext or onCompleted. In addition, it samples values only once, so unless a new source value appears, the sampler won't emit the last value.

@benjchristensen
Copy link
Member

@headinthebox Why does it behave this way?

@headinthebox
Copy link
Contributor

The overload with sampler was introduced as we went through the API and changed everything that took time and added an overload that takes an Observable.

When you sample using interval d, it is as if you are giving it an infinite Observable.interval(d).

However, it would make sense if it behaved like zip where the result stream terminates when either of the input stream terminates or throws.

Nice catch.

@headinthebox
Copy link
Contributor

What is the issue with SkipUntil?

That one throws when "other" throw, and skips until it produces a regular value. It ignores onCompleted.
Same for TakeUntil.

@akarnokd
Copy link
Member Author

akarnokd commented Dec 6, 2013

I'll change the code to behave like zip. SkipUntil: I usually scratch my head when I see an operator returning an Observable which never terminates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants