Subscribing and unsubscribing

The Observable.subscribe() method has many overloads as follows:

  • subscribe(): This one ignores all the emissions from the Observable instance and throws an OnErrorNotImplementedException exception if there is an OnError notification. This can be used to only trigger the OnSubscribe.call behavior.
  • subscribe(Action1<? super T>): This only subscribes to onNext() method-triggered updates. It ignores the OnCompleted notification and throws an OnErrorNotImplementedException exception if there is an OnError notification. It is not a good choice for real production code, because it is hard to guarantee that no errors will be thrown.
  • subscribe(Action1<? super T>, Action1<Throwable>): This is the same as preceding one, but the ...

Get Learning Reactive Programming with Java 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.