SlideShare a Scribd company logo
RxJava2
Should I use it?
RxJava2
1. What’s new?
2. Performance
3. Libraries compatibility
4. RxJava1 compatibility
5. Summary
What’s new?
● Reactive Streams compatibility
● Observable types
● Null handling
● Backpressure handling
● Testing
Reactive Streams
“Reactive Streams is an initiative to provide a standard for asynchronous
stream processing with non-blocking back pressure. This encompasses efforts
aimed at runtime environments (JVM and JavaScript) as well as network
protocols.”
Reactive Streams
public interface Publisher<T> {
public void subscribe(Subscriber<? super T> s);
}
public interface Subscriber< T> {
public void onSubscribe (Subscription s) ;
public void onNext(T t);
public void onError(Throwable t) ;
public void onComplete();
}
Reactive Streams
public interface Subscription {
public void request(long n);
public void cancel();
}
public interface Processor<T, R> extends Subscriber<T>, Publisher<R> {
}
Observable types
Type Description
Flowable<T> Emits 0 or n items and terminates with complete or an
error. Supports backpressure, which allows to control
how fast a source emits items.
Observable<T> Emits 0 or n items and terminates with complete or an
error.
Single<T> Emits either a single item or an error. The reactive
version of a method call. You subscribe to a Single and
you get either a return value or an error.
Maybe<T> Succeeds with an item, or no item, or errors. The
reactive version of an Optional.
Completable Either completes or returns an error. It never return
items. The reactive version of a Runnable.
Null handling
Observable.just(null);
Single.just(null);
Observable.fromCallable(() -> null)
.subscribe(System. out::println, Throwable::printStackTrace) ;
Observable.just(1).map(v -> null)
.subscribe(System. out::println, Throwable::printStackTrace) ;
Null handling
Solution:
enum Irrelevant { INSTANCE }
Single.just(1).map(v -> Irrelevant. INSTANCE);
Backpressure handling
private Flowable<Integer> createFlowable (int items,
BackpressureStrategy backpressureStrategy) {
return Flowable.create(subscriber -> {
for (int i = 0; i < items; i++) {
if (subscriber.isCancelled()) {
return;
}
subscriber.onNext(i) ;
}
subscriber.onComplete() ;
}, backpressureStrategy) ;
}
Backpressure handling
● BackpressureStrategy.BUFFER
● BackpressureStrategy.DROP
● BackpressureStrategy.LATEST
● BackpressureStrategy.ERROR
● BackpressureStrategy.MISSING
Testing
@Test
public void testUsingTestObserver () {
//given
TestObserver<String> observer = new TestObserver<>() ;
Observable<String> observable = Observable. fromIterable(WORDS)
.zipWith(Observable. range(1, Integer.MAX_VALUE),
(string, index) -> String. format("%2d. %s", index, string));
//when
observable.subscribe(observer) ;
//then
observer.assertComplete() ;
observer.assertNoErrors() ;
observer.assertValueCount( 9);
assertThat(observer.values() , hasItem(" 4. fox"));
}
Testing
//given
TestObserver<String> observer = new TestObserver<>() ;
Observable<String> observable = Observable. fromIterable(WORDS)
.zipWith(Observable. range(1, Integer.MAX_VALUE),
(string, index) -> String. format("%2d. %s", index, string))
.subscribeOn(Schedulers. computation());
//when
observable.subscribe(observer) ;
//then
observer.assertComplete() ;
observer.assertNoErrors() ;
observer.assertValueCount( 4);
assertThat(observer.values() , hasItem(" 4. fox"));
Testing
public class ImmediateSchedulerRule implements TestRule {
@Override
public Statement apply(final Statement base , Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxJavaPlugins. setIoSchedulerHandler(build(Schedulers. trampoline()));
RxJavaPlugins. setComputationSchedulerHandler(build(Schedulers. trampoline()));
RxJavaPlugins. setNewThreadSchedulerHandler(build(Schedulers. trampoline()));
try {
base.evaluate() ;
} finally {
RxJavaPlugins. reset();
}
}
};
Testing
@Rule
public final ImmediateSchedulerRule testSchedulerRule
= new ImmediateSchedulerRule() ;
Testing
@Test
public void testUsingTestObserver () {
//given
TestObserver<String> observer ;
Observable<String> observable = Observable. fromIterable(WORDS)
.zipWith(Observable. range(1, Integer.MAX_VALUE),
(string, index) -> String. format("%2d. %s", index, string))
.subscribeOn(Schedulers. computation());
//when
observer = observable.test() ;
//then
observer.assertComplete() ;
observer.assertNoErrors() ;
observer.assertValueCount( 4);
assertThat(observer.values() , hasItem(" 4. fox"));
}
Performance
Libraries compatibility
● Retrofit READY
● Realm NOT
● Requery READY
● SugarOrm NOT
● Ormlite NOT
● GreenDao NOT
● Firebase NOT (wrapper libraries)
● SqlBrite NOT
RxJava 1 compatibility
github.com/akarnokd/RxJava2Interop
RxJava 1 compatibility
github.com/akarnokd/RxJava2Interop
Should I switch to RxJava2?
Ad

More Related Content

What's hot (20)

Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
NAVER / MusicPlatform
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
Alex Miller
 
6 Synchronisation
6 Synchronisation6 Synchronisation
6 Synchronisation
Dr. Loganathan R
 
Qt Framework Events Signals Threads
Qt Framework Events Signals ThreadsQt Framework Events Signals Threads
Qt Framework Events Signals Threads
Neera Mital
 
Java Concurrency Idioms
Java Concurrency IdiomsJava Concurrency Idioms
Java Concurrency Idioms
Alex Miller
 
2009 03-26 grails-testing
2009 03-26 grails-testing2009 03-26 grails-testing
2009 03-26 grails-testing
geoffnettaglich
 
TDC 2015 SP - O ciclo de vida de aplicações UWP
TDC 2015 SP - O ciclo de vida de aplicações UWP TDC 2015 SP - O ciclo de vida de aplicações UWP
TDC 2015 SP - O ciclo de vida de aplicações UWP
Vitor Meriat
 
Angular2 rxjs
Angular2 rxjsAngular2 rxjs
Angular2 rxjs
Christoffer Noring
 
Transactions
TransactionsTransactions
Transactions
ashish61_scs
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
Kyung Yeol Kim
 
J2ee Transaction Overview
J2ee Transaction OverviewJ2ee Transaction Overview
J2ee Transaction Overview
Terry Cho
 
React tips
React tipsReact tips
React tips
Vedran Maršić
 
Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using AutomataModeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
Daniel Bristot de Oliveira
 
Tdd guide
Tdd guideTdd guide
Tdd guide
Hanokh Aloni
 
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho PolutaInfinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum
 
Sistemas de control a tiempo discreto por Guillermo Guzmán
Sistemas de control a tiempo discreto por Guillermo GuzmánSistemas de control a tiempo discreto por Guillermo Guzmán
Sistemas de control a tiempo discreto por Guillermo Guzmán
GuillermoGuzmn16
 
Os3
Os3Os3
Os3
gopal10scs185
 
Effective java - concurrency
Effective java - concurrencyEffective java - concurrency
Effective java - concurrency
feng lee
 
Clojure concurrency overview
Clojure concurrency overviewClojure concurrency overview
Clojure concurrency overview
Sergey Stupin
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
NAVER / MusicPlatform
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
Alex Miller
 
Qt Framework Events Signals Threads
Qt Framework Events Signals ThreadsQt Framework Events Signals Threads
Qt Framework Events Signals Threads
Neera Mital
 
Java Concurrency Idioms
Java Concurrency IdiomsJava Concurrency Idioms
Java Concurrency Idioms
Alex Miller
 
2009 03-26 grails-testing
2009 03-26 grails-testing2009 03-26 grails-testing
2009 03-26 grails-testing
geoffnettaglich
 
TDC 2015 SP - O ciclo de vida de aplicações UWP
TDC 2015 SP - O ciclo de vida de aplicações UWP TDC 2015 SP - O ciclo de vida de aplicações UWP
TDC 2015 SP - O ciclo de vida de aplicações UWP
Vitor Meriat
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
Kyung Yeol Kim
 
J2ee Transaction Overview
J2ee Transaction OverviewJ2ee Transaction Overview
J2ee Transaction Overview
Terry Cho
 
Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using AutomataModeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
Daniel Bristot de Oliveira
 
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho PolutaInfinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum
 
Sistemas de control a tiempo discreto por Guillermo Guzmán
Sistemas de control a tiempo discreto por Guillermo GuzmánSistemas de control a tiempo discreto por Guillermo Guzmán
Sistemas de control a tiempo discreto por Guillermo Guzmán
GuillermoGuzmn16
 
Effective java - concurrency
Effective java - concurrencyEffective java - concurrency
Effective java - concurrency
feng lee
 
Clojure concurrency overview
Clojure concurrency overviewClojure concurrency overview
Clojure concurrency overview
Sergey Stupin
 

Similar to Rx java2 - Should I use it? (20)

Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2
Yakov Fain
 
Reactive Streams and RxJava2
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2
Yakov Fain
 
Welcome to rx java2
Welcome to rx java2Welcome to rx java2
Welcome to rx java2
Paresh Dudhat
 
Reactive mesh
Reactive meshReactive mesh
Reactive mesh
Kalin Maldzhanski
 
The Next Step for Reactive Android Programming
The Next Step for Reactive Android ProgrammingThe Next Step for Reactive Android Programming
The Next Step for Reactive Android Programming
Tomasz Polanski
 
Iniciación rx java
Iniciación rx javaIniciación rx java
Iniciación rx java
Elisa De Gregorio Medrano
 
Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2
JollyRogers5
 
rxJava 2 tips and tricks
rxJava 2 tips and tricks rxJava 2 tips and tricks
rxJava 2 tips and tricks
Stepan Goncharov
 
Reactive Streams Condensed
Reactive Streams CondensedReactive Streams Condensed
Reactive Streams Condensed
Artur Skowroński
 
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Spring Framework 5.0による Reactive Web Application #JavaDayTokyoSpring Framework 5.0による Reactive Web Application #JavaDayTokyo
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Toshiaki Maki
 
Reactive Everywhere
Reactive EverywhereReactive Everywhere
Reactive Everywhere
trion development GmbH
 
RxJava from the trenches
RxJava from the trenchesRxJava from the trenches
RxJava from the trenches
Peter Hendriks
 
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
Codemotion
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...
Mario Fusco
 
Reactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJavaReactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJava
Matt Stine
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & design
allegro.tech
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVM
Netesh Kumar
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
Rick Warren
 
RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 Slides
YarikS
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
CongTrung Vnit
 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2
Yakov Fain
 
Reactive Streams and RxJava2
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2
Yakov Fain
 
The Next Step for Reactive Android Programming
The Next Step for Reactive Android ProgrammingThe Next Step for Reactive Android Programming
The Next Step for Reactive Android Programming
Tomasz Polanski
 
Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2
JollyRogers5
 
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Spring Framework 5.0による Reactive Web Application #JavaDayTokyoSpring Framework 5.0による Reactive Web Application #JavaDayTokyo
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Toshiaki Maki
 
RxJava from the trenches
RxJava from the trenchesRxJava from the trenches
RxJava from the trenches
Peter Hendriks
 
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
Codemotion
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...
Mario Fusco
 
Reactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJavaReactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJava
Matt Stine
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & design
allegro.tech
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVM
Netesh Kumar
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
Rick Warren
 
RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 Slides
YarikS
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
CongTrung Vnit
 
Ad

Recently uploaded (20)

Shift Right Security for EKS Webinar Slides
Shift Right Security for EKS Webinar SlidesShift Right Security for EKS Webinar Slides
Shift Right Security for EKS Webinar Slides
Anchore
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
SamFw Tool v4.9 Samsung Frp Tool Free Download
SamFw Tool v4.9 Samsung Frp Tool Free DownloadSamFw Tool v4.9 Samsung Frp Tool Free Download
SamFw Tool v4.9 Samsung Frp Tool Free Download
Iobit Uninstaller Pro Crack
 
File Viewer Plus 7.5.5.49 Crack Full Version
File Viewer Plus 7.5.5.49 Crack Full VersionFile Viewer Plus 7.5.5.49 Crack Full Version
File Viewer Plus 7.5.5.49 Crack Full Version
raheemk1122g
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
Hyper Casual Game Developers Company
Hyper  Casual  Game  Developers  CompanyHyper  Casual  Game  Developers  Company
Hyper Casual Game Developers Company
Nova Carter
 
Lumion Pro Crack + 2025 Activation Key Free Code
Lumion Pro Crack + 2025 Activation Key Free CodeLumion Pro Crack + 2025 Activation Key Free Code
Lumion Pro Crack + 2025 Activation Key Free Code
raheemk1122g
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
Quasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoersQuasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoers
sadadkhah
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
S3 + AWS Athena how to integrate s3 aws plus athena
S3 + AWS Athena how to integrate s3 aws plus athenaS3 + AWS Athena how to integrate s3 aws plus athena
S3 + AWS Athena how to integrate s3 aws plus athena
aianand98
 
cram_advancedword2007version2025final.ppt
cram_advancedword2007version2025final.pptcram_advancedword2007version2025final.ppt
cram_advancedword2007version2025final.ppt
ahmedsaadtax2025
 
GC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance EngineeringGC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance Engineering
Tier1 app
 
Welcome to QA Summit 2025.
Welcome to QA Summit 2025.Welcome to QA Summit 2025.
Welcome to QA Summit 2025.
QA Summit
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Hydraulic Modeling And Simulation Software Solutions.pptx
Hydraulic Modeling And Simulation Software Solutions.pptxHydraulic Modeling And Simulation Software Solutions.pptx
Hydraulic Modeling And Simulation Software Solutions.pptx
julia smits
 
IObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download FreeIObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download Free
Iobit Uninstaller Pro Crack
 
Shift Right Security for EKS Webinar Slides
Shift Right Security for EKS Webinar SlidesShift Right Security for EKS Webinar Slides
Shift Right Security for EKS Webinar Slides
Anchore
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
File Viewer Plus 7.5.5.49 Crack Full Version
File Viewer Plus 7.5.5.49 Crack Full VersionFile Viewer Plus 7.5.5.49 Crack Full Version
File Viewer Plus 7.5.5.49 Crack Full Version
raheemk1122g
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
Hyper Casual Game Developers Company
Hyper  Casual  Game  Developers  CompanyHyper  Casual  Game  Developers  Company
Hyper Casual Game Developers Company
Nova Carter
 
Lumion Pro Crack + 2025 Activation Key Free Code
Lumion Pro Crack + 2025 Activation Key Free CodeLumion Pro Crack + 2025 Activation Key Free Code
Lumion Pro Crack + 2025 Activation Key Free Code
raheemk1122g
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
Quasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoersQuasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoers
sadadkhah
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
S3 + AWS Athena how to integrate s3 aws plus athena
S3 + AWS Athena how to integrate s3 aws plus athenaS3 + AWS Athena how to integrate s3 aws plus athena
S3 + AWS Athena how to integrate s3 aws plus athena
aianand98
 
cram_advancedword2007version2025final.ppt
cram_advancedword2007version2025final.pptcram_advancedword2007version2025final.ppt
cram_advancedword2007version2025final.ppt
ahmedsaadtax2025
 
GC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance EngineeringGC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance Engineering
Tier1 app
 
Welcome to QA Summit 2025.
Welcome to QA Summit 2025.Welcome to QA Summit 2025.
Welcome to QA Summit 2025.
QA Summit
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Hydraulic Modeling And Simulation Software Solutions.pptx
Hydraulic Modeling And Simulation Software Solutions.pptxHydraulic Modeling And Simulation Software Solutions.pptx
Hydraulic Modeling And Simulation Software Solutions.pptx
julia smits
 
IObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download FreeIObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download Free
Iobit Uninstaller Pro Crack
 
Ad

Rx java2 - Should I use it?

  • 2. RxJava2 1. What’s new? 2. Performance 3. Libraries compatibility 4. RxJava1 compatibility 5. Summary
  • 3. What’s new? ● Reactive Streams compatibility ● Observable types ● Null handling ● Backpressure handling ● Testing
  • 4. Reactive Streams “Reactive Streams is an initiative to provide a standard for asynchronous stream processing with non-blocking back pressure. This encompasses efforts aimed at runtime environments (JVM and JavaScript) as well as network protocols.”
  • 5. Reactive Streams public interface Publisher<T> { public void subscribe(Subscriber<? super T> s); } public interface Subscriber< T> { public void onSubscribe (Subscription s) ; public void onNext(T t); public void onError(Throwable t) ; public void onComplete(); }
  • 6. Reactive Streams public interface Subscription { public void request(long n); public void cancel(); } public interface Processor<T, R> extends Subscriber<T>, Publisher<R> { }
  • 7. Observable types Type Description Flowable<T> Emits 0 or n items and terminates with complete or an error. Supports backpressure, which allows to control how fast a source emits items. Observable<T> Emits 0 or n items and terminates with complete or an error. Single<T> Emits either a single item or an error. The reactive version of a method call. You subscribe to a Single and you get either a return value or an error. Maybe<T> Succeeds with an item, or no item, or errors. The reactive version of an Optional. Completable Either completes or returns an error. It never return items. The reactive version of a Runnable.
  • 8. Null handling Observable.just(null); Single.just(null); Observable.fromCallable(() -> null) .subscribe(System. out::println, Throwable::printStackTrace) ; Observable.just(1).map(v -> null) .subscribe(System. out::println, Throwable::printStackTrace) ;
  • 9. Null handling Solution: enum Irrelevant { INSTANCE } Single.just(1).map(v -> Irrelevant. INSTANCE);
  • 10. Backpressure handling private Flowable<Integer> createFlowable (int items, BackpressureStrategy backpressureStrategy) { return Flowable.create(subscriber -> { for (int i = 0; i < items; i++) { if (subscriber.isCancelled()) { return; } subscriber.onNext(i) ; } subscriber.onComplete() ; }, backpressureStrategy) ; }
  • 11. Backpressure handling ● BackpressureStrategy.BUFFER ● BackpressureStrategy.DROP ● BackpressureStrategy.LATEST ● BackpressureStrategy.ERROR ● BackpressureStrategy.MISSING
  • 12. Testing @Test public void testUsingTestObserver () { //given TestObserver<String> observer = new TestObserver<>() ; Observable<String> observable = Observable. fromIterable(WORDS) .zipWith(Observable. range(1, Integer.MAX_VALUE), (string, index) -> String. format("%2d. %s", index, string)); //when observable.subscribe(observer) ; //then observer.assertComplete() ; observer.assertNoErrors() ; observer.assertValueCount( 9); assertThat(observer.values() , hasItem(" 4. fox")); }
  • 13. Testing //given TestObserver<String> observer = new TestObserver<>() ; Observable<String> observable = Observable. fromIterable(WORDS) .zipWith(Observable. range(1, Integer.MAX_VALUE), (string, index) -> String. format("%2d. %s", index, string)) .subscribeOn(Schedulers. computation()); //when observable.subscribe(observer) ; //then observer.assertComplete() ; observer.assertNoErrors() ; observer.assertValueCount( 4); assertThat(observer.values() , hasItem(" 4. fox"));
  • 14. Testing public class ImmediateSchedulerRule implements TestRule { @Override public Statement apply(final Statement base , Description description) { return new Statement() { @Override public void evaluate() throws Throwable { RxJavaPlugins. setIoSchedulerHandler(build(Schedulers. trampoline())); RxJavaPlugins. setComputationSchedulerHandler(build(Schedulers. trampoline())); RxJavaPlugins. setNewThreadSchedulerHandler(build(Schedulers. trampoline())); try { base.evaluate() ; } finally { RxJavaPlugins. reset(); } } };
  • 15. Testing @Rule public final ImmediateSchedulerRule testSchedulerRule = new ImmediateSchedulerRule() ;
  • 16. Testing @Test public void testUsingTestObserver () { //given TestObserver<String> observer ; Observable<String> observable = Observable. fromIterable(WORDS) .zipWith(Observable. range(1, Integer.MAX_VALUE), (string, index) -> String. format("%2d. %s", index, string)) .subscribeOn(Schedulers. computation()); //when observer = observable.test() ; //then observer.assertComplete() ; observer.assertNoErrors() ; observer.assertValueCount( 4); assertThat(observer.values() , hasItem(" 4. fox")); }
  • 18. Libraries compatibility ● Retrofit READY ● Realm NOT ● Requery READY ● SugarOrm NOT ● Ormlite NOT ● GreenDao NOT ● Firebase NOT (wrapper libraries) ● SqlBrite NOT
  • 21. Should I switch to RxJava2?
  翻译: