Chapter 2. Reactive Extensions
This chapter will guide you through the core concepts related to Reactive Extensions and RxJava.
You will become very comfortable with Observable<T>, Observer<T>, and Subscriber<T> and a few helpful utility methods called operators.
Observable is the core API RxJava, so make sure you understand how it works and what it represents.
Throughout this chapter, you will learn what Observable really is and how to create it and interact with it.
The knowledge you gain is essential to idiomatically provide and consume reactive APIs based on RxJava.
RxJava was designed to ease the pain of asynchronous and event-driven programming, but you must understand some core principles and semantics in order to take advantage of that.
When you grasp how Observable collaborates with client code, you will feel a lot of power under your fingertips.
After reading this chapter, you will be capable of creating simple streams of data, ready to be combined and composed in very interesting ways.
Anatomy of rx.Observable
rx.Observable<T> represent a flowing sequence of values.
It is the abstraction that you will use all of the time.
Because these
values often appear over a wide time range, we tend to think about an Observable as a stream of events.
If you look around you will find many examples of streams:
-
User interface events
-
Bytes transferred over the network
-
New orders in online shopping
-
Posts on social-media websites
If you want to compare Observable<T> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access