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

Hot and cold Observable instances


Looking at the previous examples implemented using the Observable.create(), Observable.just(), and Observable.from() methods, we can say that until someone subscribes to them, they are inactive and don't emit anything. However, each time someone subscribes, they start emitting their notifications. For example, if we subscribe three times to an Observable.from(Iterable) object, the Iterable instance will be iterated three times. The Observable instances behaving like that are called cold Observable instances.

All of the factory methods we've been using in this chapter return cold Observables. Cold Observables produce notifications on demand, and for every Subscriber, they produce independent notifications.

There are Observable instances which, when they start emitting notifications, it doesn't matter if there are subscriptions to them or not. They continue emitting them until completion. All the subscribers receive the same notifications, and by default, when...