Recently I'm trying to leverage RxJava in my projects and I find myself have difficulties in perceiving the spirit of its design.
I think RxJava is the extension of Observer Pattern. And if so, then there would be observers and observables in this pattern.
The mechanism work like this:
- An observer subscribes to an observable.
- When the state of the observable changes, it will notify its observer.
Here comes my problem:
As the RxJava official doc pointed out:
In ReactiveX an observer subscribes to an Observable.
but in the code of the Observable class,
public final void subscribe(Observer<? super T> observer) {
...
}
What is the meaning of the word "subscribe" here? Why don't they use "subscribe to" or "subscribed by"?
Aucun commentaire:
Enregistrer un commentaire