Learning RxJava
eBook - ePub

Learning RxJava

Thomas Nield

Condividi libro
  1. 400 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Learning RxJava

Thomas Nield

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

Reactive Programming with Java and ReactiveXAbout This Book• Explore the essential tools and operators RxJava provides, and know which situations to use them in• Delve into Observables and Subscribers, the core components of RxJava used for building scalable and performant reactive applications• Delve into the practical implementation of tools to effectively take on complex tasks such as concurrency and backpressureWho This Book Is ForThe primary audience for this book is developers with at least a fundamental mastery of Java.Some readers will likely be interested in RxJava to make programs more resilient, concurrent, and scalable. Others may be checking out reactive programming just to see what it is all about, and to judge whether it can solve any problems they may have.What You Will Learn• Learn the features of RxJava 2 that bring about many significant changes, including new reactive types such as Flowable, Single, Maybe, and Completable• Understand how reactive programming works and the mindset to "think reactively"• Demystify the Observable and how it quickly expresses data and events as sequences• Learn the various Rx operators that transform, filter, and combine data and event sequences• Leverage multicasting to push data to multiple destinations, and cache and replay them• Discover how concurrency and parallelization work in RxJava, and how it makes these traditionally complex tasks trivial to implement• Apply RxJava and Retrolambda to the Android domain to create responsive Android apps with better user experiences• Use RxJava with the Kotlin language to express RxJava more idiomatically with extension functions, data classes, and other Kotlin featuresIn DetailRxJava is a library for composing asynchronous and event-based programs using Observable sequences for the JVM, allowing developers to build robust applications in less time.Learning RxJava addresses all the fundamentals of reactive programming to help readers write reactive code, as well as teach them an effective approach to designing and implementing reactive libraries and applications.Starting with a brief introduction to reactive programming concepts, there is an overview of Observables and Observers, the core components of RxJava, and how to combine different streams of data and events together. You will also learn simpler ways to achieve concurrency and remain highly performant, with no need for synchronization. Later on, we will leverage backpressure and other strategies to cope with rapidly-producing sources to prevent bottlenecks in your application. After covering custom operators, testing, and debugging, the book dives into hands-on examples using RxJava on Android as well as Kotlin.Style and approachThis book will be different from other Rx books, taking an approach that comprehensively covers Rx concepts and practical applications.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Learning RxJava è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Learning RxJava di Thomas Nield in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Computer Science e Programming in Java. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
2017
ISBN
9781787123748
Edizione
1

Observables and Subscribers

We already got a glimpse into the Observable and how it works in Chapter 1, Thinking Reactively. You probably have many questions on how exactly it operates and what practical applications it holds. This chapter will provide a foundation for understanding how an Observable works as well as the critical relationship it has with the Observer. We will also cover several ways to create an Observable as well make it useful by covering a few operators. To make the rest of the book flow smoothly, we will also cover all critical nuances head-on to build a solid foundation and not leave you with surprises later.
Here is what we will cover in this chapter:
  • The Observable
  • The Observer
  • Other Observable factories
  • Single, Completable, and Maybe
  • Disposable

The Observable

As introduced in Chapter 1, Thinking Reactively, the Observable is a push-based, composable iterator. For a given Observable<T>, it pushes items (called emissions) of type T through a series of operators until it finally arrives at a final Observer, which consumes the items. We will cover several ways to create an Observable, but first, let's dive into how an Observable works through its onNext(), onCompleted(), and onError() calls.

How Observables work

Before we do anything else, we need to study how an Observable sequentially passes items down a chain to an Observer. At the highest level, an Observable works by passing three types of events:
  • onNext(): This passes each item one at a time from the source Observable all the way down to the Observer.
  • onComplete(): This communicates a completion event all the way down to the Observer, indicating that no more onNext() calls will occur.
  • onError(): This communicates an error up the chain to the Observer, where the Observer typically defines how to handle it. Unless a retry() operator is used to intercept the error, the Observable chain typically terminates, and no more emissions will occur.
These three events are abstract methods in the Observer type, and we will cover some of the implementation later. For now, we will focus pragmatically on how they work in everyday usage.
In RxJava 1.0, the onComplete() event is actually called onCompleted().

Using Observable.create()

Let's start with creating a source Observable using Observable.create(). Relatively speaking, a source Observable is an Observable where emissions originate from and is the starting point of our Observable chain.
The Observable.create() factory allows us to create an Observable by providing a lambda receiving an Observable emitter. We can call the Observable e...

Indice dei contenuti