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

2.x Observer vs Subscriber. Just to clarify. #4515

Closed
VictorAlbertos opened this issue Sep 8, 2016 · 3 comments
Closed

2.x Observer vs Subscriber. Just to clarify. #4515

VictorAlbertos opened this issue Sep 8, 2016 · 3 comments
Labels

Comments

@VictorAlbertos
Copy link
Contributor

In 1.x the difference between Observer and Subscriber is that a Subscriber allows to subscribe and unsubscribe, however an Observer only allows to subscribe.

But in 2.x Observer is used to subscribe to an Observable, and Subscriber is used to subscribe to a Flowable. And if you want to be able to unsubscribe, you need to use ResourceObserver and ResourceSubscriber respectively.

Is that right?

Thanks.

@akarnokd
Copy link
Member

akarnokd commented Sep 8, 2016

Yes.

@ScottCooper92
Copy link

Hi, I realise this is an old issue but I'd like some further clarification.

The distinction between a Subscriber and an Observer is that Subscribers are part of the Reactive Stream specification, where the first rule of Subscribers is that they must "MUST signal demand via Subscription.request(long n) to receive onNext signals."

Since Observables don't have backpressure support, and therefore don't signal demand via request(long n), they use Observer, which doesn't have the request method.

Am I on the right track?

@akarnokd
Copy link
Member

akarnokd commented Mar 1, 2017

Since Observables don't have backpressure support, there is no need for a Subscription with a request() method. To avoid some confusion, separate "connection" types is employed: Disposable with a dispose() method that is analogous to Subscription.cancel().

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

No branches or pull requests

3 participants