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

Scheduling should serialize notifications. #3542

Closed
Dorus opened this issue Nov 27, 2015 · 3 comments
Closed

Scheduling should serialize notifications. #3542

Dorus opened this issue Nov 27, 2015 · 3 comments

Comments

@Dorus
Copy link

Dorus commented Nov 27, 2015

Currently, onError cuts ahead of onNext calls when you schedule work, but does not (cannot) when you use a single thread.

Observable.create(o -> {
    o.onNext(1);
    o.onError(new NotImplementedException());
})
.observeOn(Schedulers.newThread())
.subscribe(i -> System.out.println(i), 
        e -> System.out.println("error:" + e));

This yields error instead of 1, error as expected. Other implementations of Rx like Rx.Net do serialize notifications. This 'cut ahead' behavior is actually described as a common pitfall in RxJava by some.

@akarnokd
Copy link
Member

RxJava 2.0 will allow you to customize this behavior in many operators, including observeOn, delay, combineLatest, zip, groupBy, onBackpressureBuffer, skipLast and takeLast.

I was planning to post a PR targeting observeOn to remove some unnecessary code (#3002) and may well do this as well.

@Dorus
Copy link
Author

Dorus commented Dec 3, 2015

This is really scary nondeterministic behavior, and against Rx contract. I hope the (future) default will be to not lose data. If anything it might be an appropriate setting on the subscriber.

@akarnokd
Copy link
Member

The observeOn operator received an overload that takes a delayError parameter you can set.

Closing via #3682.

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

No branches or pull requests

2 participants