EDITED : with comment by @Alrid
TL; DR
public abstract class Subscriber<T> implements Observer<T>, Subscription
So, Subscriber is an implementation of Observer , with additional subscription semantics (more about non-subscription). The code in your question just shows that it passes the Observer interface instead of the implementation (common programming practice).
This code also returns a Subscription , which may be due to the fact that the author of this code believed that the client should have access only to the Subscription methods without access to the elements created by the observables. This may be a programmer error.
long story
Indeed, you should read the contents of this website (or book): http://www.introtorx.com It's about Rx.Net, but the concepts are the same, they were created by Eric Majer and the RxJava developers who follow them (if Applicable to Java language).
This page will interest you (this is the second chapter): KeyTypes
Here you will read in the first paragraphs:
There are two key types to understand when working with Rx, and a subset of helper types to help you learn more about Rx. IObserver and IObservable form the basic building blocks for Rx, and ISubject implementations reduce the learning curve for developers new to Rx.
...
Essentially, Rx is built around the Observer..NET pattern already provides some other ways to implement the Observer pattern, such as multicast delegates or events (which are usually multicast delegates).
Even if the types / APIs are slightly different, you will learn a lot with this book, perhaps more than with some blogs.
What this book does not say (... because it is in the implementation of RxJava)
The main RxJava developer introduced a small change at this time (see PR # 792 ), which allowed distinguishing between two types of contracts:
- notice →
Observer - (un) subscription →
Subscription
This change allowed us to better express / share these problems with the implementing classes of the RxJava library.
However, as a library user, using actual RxJava library implementations should be good enough.
The implementation of the subscriber requires much more knowledge, work and care, indeed, the semantics of the subscription is very important depending on the type of source observed (hot or cold? Expensive to create?)
Identifying Subscriber rather than Observer in such cases as indicated above will not interfere with the code in most cases, but this is not intended for it if semantics are needed without subscription. But in the end, the implementation of Subscriber may include some pitfalls, such as:
- spend resources on functionality that you will not use
- cannot inherit another class
- write the wrong code without a subscription
- copy / paste the code with the wrong code or the correct code written for a different context.