Book Image

Learning Reactive Programming with Java 8

By : Nickolay Tzvetinov
Book Image

Learning Reactive Programming with Java 8

By: Nickolay Tzvetinov

Overview of this book

Table of Contents (15 chapters)
Learning Reactive Programming with Java 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 second parameter is called if there is an OnError notification.

  • subscribe(Action1<? super T>,Action1<Throwable>, Action0): This is the same as the preceding one, but the third parameter is called on OnCompleted notification...