SlideShare a Scribd company logo
1 of 14
Welcome to RxJava2
RxJava is a port from Reactive Extensions (Rx) to Java.
RxJava was open sourced 2014 and is hosted at http://reactivex.io/.
ReactiveX
• The Observer pattern done right.
• ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator
pattern, and functional programming.
• To understand different operators from Rx visit http://rxmarbles.com/
Benefits
• It removes complex management of Threads and States.
• It removes “Callback Hell”
• Removes redundant calls to database or webservices with the help of
cache.
• Helps to write Clean and Testable code.
Observer Pattern
• The observer pattern is a software
design pattern in which an object,
called the subject, maintains a list of its
dependents, called observers, and
notifies them automatically of any
state changes, usually by calling one of
their methods.
• It is mainly used to implement
distributed event handling systems.
Type of Observables
• Flowable<T>
• Observable<T>
• Single<T>
• Maybe<T>
• Completable
Observable
Observable<Todo> todoObservable = Observable.create(emitter -> {
try {
List<Todo> todos = getTodos();
for (Todo todo : todos) {
emitter.onNext(todo);
}
emitter.onComplete();
} catch (Exception e) {
emitter.onError(e);
}
});
Maybe
Maybe<List<Todo>> todoMaybe = Maybe.create(emitter -> {
try {
List<Todo> todos = getTodos();
if(todos != null && !todos.isEmpty()) {
emitter.onSuccess(todos);
}else {
emitter.onComplete();
}
} catch (Exception e) {
emitter.onError(e);
}
});
Single<T> and Completable
Single<T> objects are similar to Maybe<T> objects, but only without
the onComplete() method.
Completable objects are pretty similar to Single<T> objects, but
without return value and therefore also do not have a generic type <T>
like the other types. Completable objects can also be seen as reactive
java.lang.Runnable objects.
Observer
DisposableObserver<Todo> disposableObserver = todoObservable.subscribeWith(new DisposableObserver<Todo>() {
@Override
public void onNext(Todo t) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
Disposable
Single<List<Todo>> todosSingle = getTodos();
Disposable disposable = todosSingle.subscribeWith(new DisposableSingleObserver<List<Todo>>() {
@Override
public void onSuccess(List<Todo> todos) {
// work with the resulting todos
}
@Override
public void onError(Throwable e) {
// handle the error case
}
});
// continue working and dispose when value of the Single is not interesting any more
disposable.dispose();
Flowable<T> and Backpressure
• RxJava 2.0 introduced a new type Flowable<T>, which is pretty much the
same as an Observable<T> in regards of the API, but Flowable<T> supports
backpressure and Observable<T> does not.
• Back in RxJava 1.0 the concept of backpressure came too late and was
added to Observable<T> types, but some did throw a
MissingBackpressureException, so distinguishing between Flowable<T> and
Observable<T> is a good thing.
• Besides Observable<T> also Maybe<T>, Single<T> and Completable have
no backpressure.
Conversion
From / To Flowable Observable Maybe Single Completable
Flowable toObservable() reduce()
elementAt()
firstElement()
lastElement()
singleElement()
scan()
elementAt()
ignoreElements()
Observable toFlowable() reduce()
elementAt()
firstElement()
lastElement()
singleElement()
scan()
elementAt()
first()/firstOrError()
last()/lastOrError()
single()/singleOrErr
or()
all()/any()/count()
(and more…​)
ignoreElements()
Maybe toFlowable() toObservable() toSingle()
sequenceEqual()
toCompletable()
Single toFlowable() toObservable() toMaybe() toCompletable()
Completable toFlowable() toObservable() toMaybe() toSingle()
toSingleDefault()
Testing the observables
Observable<String> obs = ...// assume creation code here
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
obs.subscribe(testSubscriber);
testSubscriber.assertNoErrors();
List<String> chickens = testSubscriber.getOnNextEvents();
Thank you.

More Related Content

What's hot

Linking the prospective and retrospective provenance of scripts
Linking the prospective and retrospective provenance of scriptsLinking the prospective and retrospective provenance of scripts
Linking the prospective and retrospective provenance of scripts
Khalid Belhajjame
 

What's hot (20)

Java 8 Intro - Core Features
Java 8 Intro - Core FeaturesJava 8 Intro - Core Features
Java 8 Intro - Core Features
 
Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
 
Lambdas HOL
Lambdas HOLLambdas HOL
Lambdas HOL
 
Error Handling in Swift
Error Handling in SwiftError Handling in Swift
Error Handling in Swift
 
Reactive programming with RxAndroid
Reactive programming with RxAndroidReactive programming with RxAndroid
Reactive programming with RxAndroid
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Scala Code Analysis at Codacy
Scala Code Analysis at CodacyScala Code Analysis at Codacy
Scala Code Analysis at Codacy
 
Introduction to RxJava on Android
Introduction to RxJava on AndroidIntroduction to RxJava on Android
Introduction to RxJava on Android
 
Storage class
Storage classStorage class
Storage class
 
RxJava@Android
RxJava@AndroidRxJava@Android
RxJava@Android
 
AJAX and JSON
AJAX and JSONAJAX and JSON
AJAX and JSON
 
Modern Java Features
Modern Java Features Modern Java Features
Modern Java Features
 
Code craftsmanship saturdays second session
Code craftsmanship saturdays second sessionCode craftsmanship saturdays second session
Code craftsmanship saturdays second session
 
Linking the prospective and retrospective provenance of scripts
Linking the prospective and retrospective provenance of scriptsLinking the prospective and retrospective provenance of scripts
Linking the prospective and retrospective provenance of scripts
 
Lambda expression par Christophe Huntzinger
Lambda expression par Christophe HuntzingerLambda expression par Christophe Huntzinger
Lambda expression par Christophe Huntzinger
 
AWS Java SDK @ scale
AWS Java SDK @ scaleAWS Java SDK @ scale
AWS Java SDK @ scale
 
An Introduction to RxJava
An Introduction to RxJavaAn Introduction to RxJava
An Introduction to RxJava
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2
 
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
 

Viewers also liked

Government engineering college, bhavnagar 364001
Government engineering college, bhavnagar 364001Government engineering college, bhavnagar 364001
Government engineering college, bhavnagar 364001
Akash Mehta
 
2009 Sept Sentencia Sevilla Sevolucion Canon Cd
2009 Sept Sentencia Sevilla Sevolucion Canon Cd2009 Sept Sentencia Sevilla Sevolucion Canon Cd
2009 Sept Sentencia Sevilla Sevolucion Canon Cd
Gonzalo Martín
 

Viewers also liked (20)

Rocks of Aia
Rocks of AiaRocks of Aia
Rocks of Aia
 
Government engineering college, bhavnagar 364001
Government engineering college, bhavnagar 364001Government engineering college, bhavnagar 364001
Government engineering college, bhavnagar 364001
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 
Rx-Java - Como compor sua aplicacao com Observables
Rx-Java - Como compor sua aplicacao com ObservablesRx-Java - Como compor sua aplicacao com Observables
Rx-Java - Como compor sua aplicacao com Observables
 
2009 Sept Sentencia Sevilla Sevolucion Canon Cd
2009 Sept Sentencia Sevilla Sevolucion Canon Cd2009 Sept Sentencia Sevilla Sevolucion Canon Cd
2009 Sept Sentencia Sevilla Sevolucion Canon Cd
 
SimplyCompta
SimplyComptaSimplyCompta
SimplyCompta
 
Presentación1
Presentación1Presentación1
Presentación1
 
Unidad 2 trabajo 9
Unidad 2 trabajo 9Unidad 2 trabajo 9
Unidad 2 trabajo 9
 
Rxjava meetup presentation
Rxjava meetup presentationRxjava meetup presentation
Rxjava meetup presentation
 
Weather in greece
Weather in greeceWeather in greece
Weather in greece
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava
 
Social Media Strategy
Social Media StrategySocial Media Strategy
Social Media Strategy
 
Android Notifications in Android Nougat 7.0
Android Notifications in Android Nougat 7.0Android Notifications in Android Nougat 7.0
Android Notifications in Android Nougat 7.0
 
آینده کسب و کارهای تحت وب
آینده کسب و کارهای تحت وبآینده کسب و کارهای تحت وب
آینده کسب و کارهای تحت وب
 
Kmart Superblock 2.0
Kmart Superblock 2.0Kmart Superblock 2.0
Kmart Superblock 2.0
 
7 important and useful tips for your work
7 important and useful tips for your work 7 important and useful tips for your work
7 important and useful tips for your work
 
RxJava 2.0 介紹
RxJava 2.0 介紹RxJava 2.0 介紹
RxJava 2.0 介紹
 
Reactive programming with RxJava
Reactive programming with RxJavaReactive programming with RxJava
Reactive programming with RxJava
 
Modern app programming with RxJava and Eclipse Vert.x
Modern app programming with RxJava and Eclipse Vert.xModern app programming with RxJava and Eclipse Vert.x
Modern app programming with RxJava and Eclipse Vert.x
 
Creacion de bases de datos en SQL Server
Creacion de bases de datos en SQL ServerCreacion de bases de datos en SQL Server
Creacion de bases de datos en SQL Server
 

Similar to Welcome to rx java2

Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
JAXLondon2014
 

Similar to Welcome to rx java2 (20)

RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 Slides
 
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrency
 
Tech Talk #4 : RxJava and Using RxJava in MVP - Dương Văn Tới
Tech Talk #4 : RxJava and Using RxJava in MVP - Dương Văn TớiTech Talk #4 : RxJava and Using RxJava in MVP - Dương Văn Tới
Tech Talk #4 : RxJava and Using RxJava in MVP - Dương Văn Tới
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
 
Java script
Java scriptJava script
Java script
 
Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)
 
Rxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJavaRxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJava
 
Reactive Extensions: classic Observer in .NET
Reactive Extensions: classic Observer in .NETReactive Extensions: classic Observer in .NET
Reactive Extensions: classic Observer in .NET
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
Programming picaresque
Programming picaresqueProgramming picaresque
Programming picaresque
 
Lambdas : Beyond The Basics
Lambdas : Beyond The BasicsLambdas : Beyond The Basics
Lambdas : Beyond The Basics
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
An Introduction to Reactive Cocoa
An Introduction to Reactive CocoaAn Introduction to Reactive Cocoa
An Introduction to Reactive Cocoa
 
Java7
Java7Java7
Java7
 
RxJava@DAUG
RxJava@DAUGRxJava@DAUG
RxJava@DAUG
 
oojs
oojsoojs
oojs
 

Recently uploaded

Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 

Recently uploaded (20)

Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 

Welcome to rx java2

  • 1. Welcome to RxJava2 RxJava is a port from Reactive Extensions (Rx) to Java. RxJava was open sourced 2014 and is hosted at http://reactivex.io/.
  • 2. ReactiveX • The Observer pattern done right. • ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming. • To understand different operators from Rx visit http://rxmarbles.com/
  • 3. Benefits • It removes complex management of Threads and States. • It removes “Callback Hell” • Removes redundant calls to database or webservices with the help of cache. • Helps to write Clean and Testable code.
  • 4. Observer Pattern • The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. • It is mainly used to implement distributed event handling systems.
  • 5. Type of Observables • Flowable<T> • Observable<T> • Single<T> • Maybe<T> • Completable
  • 6. Observable Observable<Todo> todoObservable = Observable.create(emitter -> { try { List<Todo> todos = getTodos(); for (Todo todo : todos) { emitter.onNext(todo); } emitter.onComplete(); } catch (Exception e) { emitter.onError(e); } });
  • 7. Maybe Maybe<List<Todo>> todoMaybe = Maybe.create(emitter -> { try { List<Todo> todos = getTodos(); if(todos != null && !todos.isEmpty()) { emitter.onSuccess(todos); }else { emitter.onComplete(); } } catch (Exception e) { emitter.onError(e); } });
  • 8. Single<T> and Completable Single<T> objects are similar to Maybe<T> objects, but only without the onComplete() method. Completable objects are pretty similar to Single<T> objects, but without return value and therefore also do not have a generic type <T> like the other types. Completable objects can also be seen as reactive java.lang.Runnable objects.
  • 9. Observer DisposableObserver<Todo> disposableObserver = todoObservable.subscribeWith(new DisposableObserver<Todo>() { @Override public void onNext(Todo t) { } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
  • 10. Disposable Single<List<Todo>> todosSingle = getTodos(); Disposable disposable = todosSingle.subscribeWith(new DisposableSingleObserver<List<Todo>>() { @Override public void onSuccess(List<Todo> todos) { // work with the resulting todos } @Override public void onError(Throwable e) { // handle the error case } }); // continue working and dispose when value of the Single is not interesting any more disposable.dispose();
  • 11. Flowable<T> and Backpressure • RxJava 2.0 introduced a new type Flowable<T>, which is pretty much the same as an Observable<T> in regards of the API, but Flowable<T> supports backpressure and Observable<T> does not. • Back in RxJava 1.0 the concept of backpressure came too late and was added to Observable<T> types, but some did throw a MissingBackpressureException, so distinguishing between Flowable<T> and Observable<T> is a good thing. • Besides Observable<T> also Maybe<T>, Single<T> and Completable have no backpressure.
  • 12. Conversion From / To Flowable Observable Maybe Single Completable Flowable toObservable() reduce() elementAt() firstElement() lastElement() singleElement() scan() elementAt() ignoreElements() Observable toFlowable() reduce() elementAt() firstElement() lastElement() singleElement() scan() elementAt() first()/firstOrError() last()/lastOrError() single()/singleOrErr or() all()/any()/count() (and more…​) ignoreElements() Maybe toFlowable() toObservable() toSingle() sequenceEqual() toCompletable() Single toFlowable() toObservable() toMaybe() toCompletable() Completable toFlowable() toObservable() toMaybe() toSingle() toSingleDefault()
  • 13. Testing the observables Observable<String> obs = ...// assume creation code here TestSubscriber<String> testSubscriber = new TestSubscriber<>(); obs.subscribe(testSubscriber); testSubscriber.assertNoErrors(); List<String> chickens = testSubscriber.getOnNextEvents();