Skip to content

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

Closed
@VictorAlbertos

Description

@VictorAlbertos
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.

Activity

akarnokd

akarnokd commented on Sep 8, 2016

@akarnokd
Member

Yes.

ScottCooper92

ScottCooper92 commented on Mar 1, 2017

@ScottCooper92

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

akarnokd commented on Mar 1, 2017

@akarnokd
Member

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @akarnokd@VictorAlbertos@ScottCooper92

        Issue actions

          2.x Observer vs Subscriber. Just to clarify. · Issue #4515 · ReactiveX/RxJava