SlideShare a Scribd company logo
11
REACTIVE PROGRAMMING NO ANDROID
Guilherme Branco
Software Engineer
Guilherme Pereira Branco
@guipbranco
22
REACTIVE PROGRAMMING NO ANDROID
Guilherme Branco
Software Engineer
Guilherme Pereira Branco
@guipbranco
Reactive Programming
é do balacobaco!
Quem não usa está
por fora, meu!
Sou deveras
experiente em RxJava!
Reactive Programming no Android
55
RxJava RxAndroid
66
Reactive Programming | O Que é?
• Pull x Push: Ao invés de pedir algo e esperar, o desenvolvedor
simplesmente pede por algo e é notificado quando o resultado estiver
disponível.
• Paradigma baseado no conceito de fluxo de dados assíncrono.
• Mais flexível. O Desenvolvedor ignora se os dados chegam de forma
síncrona ou assíncrona. O código simplesmente funciona.
• Fontes de dados podem ser combinadas e não aninhadas, afastando o
desenvolvedor do “callback hell”
77
Observable Observer
Emite
item1
item2
item3
Manipula item 1
Manipula item 2
Manipula item 3
onNext(item1)
onNext(item2)
onNext(item3)
Itens acabaram onCompleted() completar
Ops! Erro… onError(error) Trata erro
Reactive Programming | Fluxo
Reactive Programming no Android
99
Anatomia | Principal Construção
Observable.from(lectureService.getLectures()) 1. Observable
.subcribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) 3. Schedulers
.subscribe(getObserver()) 2. Observer
1010
public interface LectureService {
List<Lecture> getLectures();
}
Anatomia | Principal Construção
Observable.from(lectureService.getLectures()) 1. Observable
1111
Anatomia | Principal Construção
Observable.from(lectureService.getLectures()) 1. Observable
.subcribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) 3. Schedulers
.subscribe(getObserver()) 2. Observer
1212
Anatomia | Observer / Subscriber
private Observer<Lecture> getObserver(){
return new Observer<Lecture>() {
@Override
public void onCompleted() {
Log.e(TAG, "onCompleted");
}
@Override
public void onError(Throwable e) {
Log.e(TAG, "onError: " + e.getMessage());
}
@Override
public void onNext(Lecture lecture){
Log.e(TAG, "onNext");
}
});
.subscribe(getObserver()) 2. Observer
1313
Anatomia | Principal Construção
Observable.from(lectureService.getLectures()) 1. Observable
.subcribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) 3. Schedulers
.subscribe(getObserver()) 2. Observer
ObserverObservable
=
4. Subscription
1414
Anatomia | Principal Construção
.subcribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(getObserver())
Observable<Lecture> observable = Observable.from(lectureService.getLectures()) ;
observableSubscription subscription =
1. subscription.unsubscribe()
2. CompositeSubscription compSubscription;
compSubscription.add(subscription);
3. compSubscription.unsubscribe()
1515
Exemplo | TDC
1616
public interface LectureService {
List<Lecture> getLectures();
}
Exemplo | AsyncTask
1717
new LectureAsyncTask().execute();
private class LectureAsyncTask
extends AsyncTask<String, Void, List<Lecture>>{
@Override
protected void onPreExecute() {
showLoading();
}
@Override
protected List<Lecture> doInBackground(String... params){
return lectureService.getLectures();
}
@Override
protected void onPostExecute(List<Lecture> lectures){
hideLoading();
renderItems(lectures);
}
}
Anatomia | AsyncTask -> Reactive
1818
new LectureAsyncTask().execute();
private class LectureAsyncTask
extends AsyncTask<String, Void, List<Lecture>>{
@Override
protected void onPreExecute() {
showLoading();
}
@Override
protected List<Lecture> doInBackground(String... params){
return lectureService.getLectures();
}
@Override
protected void onPostExecute(List<Lecture> lectures){
hideLoading();
renderItems(lectures);
}
}
Anatomia | AsyncTask -> Reactive
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
.toList()
1919
Anatomia | AsyncTask -> Reactive
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
.toList()
2020
new LectureAsyncTask().execute();
private class LectureAsyncTask
extends AsyncTask<String, Void, List<Lecture>>{
@Override
protected void onPreExecute() {
showLoading();
}
@Override
protected List<Lecture> doInBackground(String... params){
return lectureService.getLectures();
}
@Override
protected void onPostExecute(List<Lecture> lectures){
hideLoading();
renderItems(lectures);
}
}
Anatomia | AsyncTask -> Reactive
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
.subscribe(
new Subscriber<List<Lecture>>() {
@Override
public void onCompleted() {
hideLoading();
}
@Override
public void onError(Throwable e) {
Log.e(TAG, "onError: " + e.getMessage());
}
@Override
public void onNext(List<Lecture> lectures){
renderItems(lectures);
}
});
.toList()
2121
Anatomia | AsyncTask -> Reactive
.subscribe(
new Subscriber<List<Lecture>>() {
@Override
public void onCompleted() {
hideLoading();
}
@Override
public void onError(Throwable e) {
Log.e(TAG, "onError: " + e.getMessage());
}
@Override
public void onNext(List<Lecture> lectures){
renderItems(lectures);
}
});
2222
new LectureAsyncTask().execute();
private class LectureAsyncTask
extends AsyncTask<String, Void, List<Lecture>>{
@Override
protected void onPreExecute() {
showLoading();
}
@Override
protected List<Lecture> doInBackground(String... params){
return lectureService.getLectures();
}
@Override
protected void onPostExecute(List<Lecture> lectures){
hideLoading();
renderItems(lectures);
}
}
Anatomia | AsyncTask -> Reactive
.subscribe(
new Subscriber<List<Lecture>>() {
@Override
public void onCompleted() {
hideLoading();
}
@Override
public void onError(Throwable e) {
Log.e(TAG, "onError: " + e.getMessage());
}
@Override
public void onNext(List<Lecture> lectures){
renderItems(lectures);
}
});
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
.toList()
2323
Exemplo | AsyncTask -> Reactive
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
2424
new LectureAsyncTask().execute();
private class LectureAsyncTask
extends AsyncTask<String, Void, List<Lecture>>{
@Override
protected void onPreExecute() {
showLoading();
}
@Override
protected List<Lecture> doInBackground(String... params){
return lectureService.getLectures();
}
@Override
protected void onPostExecute(List<Lecture> lectures){
hideLoading();
renderItems(lectures);
}
}
Exemplo | AsyncTask -> Reactive
.subscribe(
new Subscriber<List<Lecture>>() {
@Override
public void onCompleted() {
hideLoading();
}
@Override
public void onError(Throwable e) {
Log.e(TAG, "onError: " + e.getMessage());
}
@Override
public void onNext(List<Lecture> lectures){
renderItems(lectures);
}
});
.toList()
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
2525
Exemplo | AsyncTask -> Reactive
.subscribe(
new Subscriber<List<Lecture>>() {
@Override
public void onCompleted() {
hideLoading();
}
@Override
public void onError(Throwable e) {
Log.e(TAG, "onError: " + e.getMessage());
}
@Override
public void onNext(List<Lecture> lectures){
renderItems(lectures);
}
});
.observeOn(AndroidSchedulers.mainThread())
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
.toList()
2626
Exemplo | RxJava
.subscribe(new Subscriber(){…});
.observeOn(AndroidSchedulers.mainThread())
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
.toList()
2727
Exemplo | TDC
2828
.subscribe(new Subscriber(){…});
.observeOn(AndroidSchedulers.mainThread())
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
.toList()
Exemplo | RxJava
2929
Operator | Filter
.filter(new Func1<Lecture, Boolean>() {
@Override
public Boolean call(Lecture lecture) {
return lecture.getDay().equalsIgnoreCase(day);
}
})
.subscribe(new Subscriber(){…});
.observeOn(AndroidSchedulers.mainThread())
Observable.from(lectureService.getLectures())
.doOnSubscribe(showLoading())
.subscribeOn(Schedulers.io())
.toList()
3030
Exemplo | TDC
3131
Exemplo | TDC
3232
Observable<Lecture> observable = getLectures();
.map(new Func1<Lecture, String>() {
@Override
public String call(Lecture lecture) {
return lecture.getDay();
}
}) // Observable<String>
.cast(CharSequence.class) // Observable<CharSequence>
Operator | Map, Cast, Distinct…
.distinct() // Mesmo Observable sem dados repetidos
.toList() // Observable<List<CharSequence>>
.subscribe(new Subscriber(){…});
observable
3333
Reactive Programming | Links
https://github.com/ReactiveX/RxJava
https://www.packtpub.com/application-development/rxjava-essentials
http://rxmarbles.com
34
http://github.com/gpbranco/rx-example-tdc
OBRIGADO.
Big Brains Wanted
Join our team! Go to arctouch.com/brjobs
Visit our booth to win an Apple Watch.
Ad

More Related Content

What's hot (18)

Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
Doug Hawkins
 
Saving lives with rx java
Saving lives with rx javaSaving lives with rx java
Saving lives with rx java
Shahar Barsheshet
 
An Introduction to RxJava
An Introduction to RxJavaAn Introduction to RxJava
An Introduction to RxJava
Sanjay Acharya
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginners
ishan0019
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
Mahmoud Samir Fayed
 
JVM Mechanics
JVM MechanicsJVM Mechanics
JVM Mechanics
Doug Hawkins
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
Tomáš Kypta
 
OSMC 2012 | Neues in Nagios 4.0 by Andreas Ericsson
OSMC 2012 | Neues in Nagios 4.0 by Andreas EricssonOSMC 2012 | Neues in Nagios 4.0 by Andreas Ericsson
OSMC 2012 | Neues in Nagios 4.0 by Andreas Ericsson
NETWAYS
 
The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185
Mahmoud Samir Fayed
 
Unit testing CourseSites Apache Filter
Unit testing CourseSites Apache FilterUnit testing CourseSites Apache Filter
Unit testing CourseSites Apache Filter
Wayan Wira
 
Java Generics
Java GenericsJava Generics
Java Generics
Carol McDonald
 
Mutation @ Spotify
Mutation @ Spotify Mutation @ Spotify
Mutation @ Spotify
STAMP Project
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
Doug Hawkins
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
Giordano Scalzo
 
Rxjs vienna
Rxjs viennaRxjs vienna
Rxjs vienna
Christoffer Noring
 
XpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp wayXpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp way
Giordano Scalzo
 
Spock Testing Framework - The Next Generation
Spock Testing Framework - The Next GenerationSpock Testing Framework - The Next Generation
Spock Testing Framework - The Next Generation
BTI360
 
java assignment
java assignmentjava assignment
java assignment
Jack Eastwood
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
Doug Hawkins
 
An Introduction to RxJava
An Introduction to RxJavaAn Introduction to RxJava
An Introduction to RxJava
Sanjay Acharya
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginners
ishan0019
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
Mahmoud Samir Fayed
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
Tomáš Kypta
 
OSMC 2012 | Neues in Nagios 4.0 by Andreas Ericsson
OSMC 2012 | Neues in Nagios 4.0 by Andreas EricssonOSMC 2012 | Neues in Nagios 4.0 by Andreas Ericsson
OSMC 2012 | Neues in Nagios 4.0 by Andreas Ericsson
NETWAYS
 
The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185
Mahmoud Samir Fayed
 
Unit testing CourseSites Apache Filter
Unit testing CourseSites Apache FilterUnit testing CourseSites Apache Filter
Unit testing CourseSites Apache Filter
Wayan Wira
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
Doug Hawkins
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
Giordano Scalzo
 
XpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp wayXpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp way
Giordano Scalzo
 
Spock Testing Framework - The Next Generation
Spock Testing Framework - The Next GenerationSpock Testing Framework - The Next Generation
Spock Testing Framework - The Next Generation
BTI360
 

Viewers also liked (20)

Interaccion Web
Interaccion WebInteraccion Web
Interaccion Web
Ricky Anthonelly Jimenez Sosa
 
Usando POP com Programação Funcional
Usando POP com Programação FuncionalUsando POP com Programação Funcional
Usando POP com Programação Funcional
Tales Andrade
 
A Gradle Story
A Gradle StoryA Gradle Story
A Gradle Story
Eduardo Felipe Ewert Bonet
 
Devs dando pitacos
Devs dando pitacosDevs dando pitacos
Devs dando pitacos
Luciano Medeiros Marcelino
 
Criando app Android utilizando Kotlin
Criando app Android utilizando KotlinCriando app Android utilizando Kotlin
Criando app Android utilizando Kotlin
Luiz Henrique Santana
 
Node.js, is it the solution for every problem?
Node.js, is it the solution for every problem?Node.js, is it the solution for every problem?
Node.js, is it the solution for every problem?
Jéferson Machado
 
Android NDK: Entrando no Mundo Nativo
Android NDK: Entrando no Mundo NativoAndroid NDK: Entrando no Mundo Nativo
Android NDK: Entrando no Mundo Nativo
Eduardo Carrara de Araujo
 
TDC Floripa - Trilha iOS - Mercado iOS no Brasil.
TDC Floripa - Trilha iOS - Mercado iOS no Brasil.TDC Floripa - Trilha iOS - Mercado iOS no Brasil.
TDC Floripa - Trilha iOS - Mercado iOS no Brasil.
Douglas Fischer
 
Dev e designer em projetos de UX, vai ter briga?!
Dev e designer em projetos de UX, vai ter briga?!Dev e designer em projetos de UX, vai ter briga?!
Dev e designer em projetos de UX, vai ter briga?!
Diego Motta
 
TDC Floripa - Trilha iOS - Debate sobre o futuro da plataforma
TDC Floripa - Trilha iOS - Debate sobre o futuro da plataformaTDC Floripa - Trilha iOS - Debate sobre o futuro da plataforma
TDC Floripa - Trilha iOS - Debate sobre o futuro da plataforma
Douglas Fischer
 
Gerenciamento de Memória em Swift - The Weak, the Strong, and the Unowned.
Gerenciamento de Memória em Swift - The Weak, the Strong, and the Unowned.Gerenciamento de Memória em Swift - The Weak, the Strong, and the Unowned.
Gerenciamento de Memória em Swift - The Weak, the Strong, and the Unowned.
Txai Wieser
 
Sucesso e derrota na Arquitetura Agile
Sucesso e derrota na Arquitetura AgileSucesso e derrota na Arquitetura Agile
Sucesso e derrota na Arquitetura Agile
Sérgio Giraldo
 
TDC2016SP - Dinâmica e Facilitações
TDC2016SP - Dinâmica e FacilitaçõesTDC2016SP - Dinâmica e Facilitações
TDC2016SP - Dinâmica e Facilitações
tdc-globalcode
 
TDC2016SP - Trilha Node.Js
TDC2016SP - Trilha Node.JsTDC2016SP - Trilha Node.Js
TDC2016SP - Trilha Node.Js
tdc-globalcode
 
Expression Language 3.0
Expression Language 3.0Expression Language 3.0
Expression Language 3.0
Everton Tavares
 
TDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQLTDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQL
tdc-globalcode
 
TDC2016SP - Trilha Mobile
TDC2016SP - Trilha MobileTDC2016SP - Trilha Mobile
TDC2016SP - Trilha Mobile
tdc-globalcode
 
TDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQLTDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQL
tdc-globalcode
 
TDC2016SP - Trilha Node.Js
TDC2016SP - Trilha Node.JsTDC2016SP - Trilha Node.Js
TDC2016SP - Trilha Node.Js
tdc-globalcode
 
TDC2016SP - Trilha DevOps Java
TDC2016SP - Trilha DevOps JavaTDC2016SP - Trilha DevOps Java
TDC2016SP - Trilha DevOps Java
tdc-globalcode
 
Usando POP com Programação Funcional
Usando POP com Programação FuncionalUsando POP com Programação Funcional
Usando POP com Programação Funcional
Tales Andrade
 
Criando app Android utilizando Kotlin
Criando app Android utilizando KotlinCriando app Android utilizando Kotlin
Criando app Android utilizando Kotlin
Luiz Henrique Santana
 
Node.js, is it the solution for every problem?
Node.js, is it the solution for every problem?Node.js, is it the solution for every problem?
Node.js, is it the solution for every problem?
Jéferson Machado
 
TDC Floripa - Trilha iOS - Mercado iOS no Brasil.
TDC Floripa - Trilha iOS - Mercado iOS no Brasil.TDC Floripa - Trilha iOS - Mercado iOS no Brasil.
TDC Floripa - Trilha iOS - Mercado iOS no Brasil.
Douglas Fischer
 
Dev e designer em projetos de UX, vai ter briga?!
Dev e designer em projetos de UX, vai ter briga?!Dev e designer em projetos de UX, vai ter briga?!
Dev e designer em projetos de UX, vai ter briga?!
Diego Motta
 
TDC Floripa - Trilha iOS - Debate sobre o futuro da plataforma
TDC Floripa - Trilha iOS - Debate sobre o futuro da plataformaTDC Floripa - Trilha iOS - Debate sobre o futuro da plataforma
TDC Floripa - Trilha iOS - Debate sobre o futuro da plataforma
Douglas Fischer
 
Gerenciamento de Memória em Swift - The Weak, the Strong, and the Unowned.
Gerenciamento de Memória em Swift - The Weak, the Strong, and the Unowned.Gerenciamento de Memória em Swift - The Weak, the Strong, and the Unowned.
Gerenciamento de Memória em Swift - The Weak, the Strong, and the Unowned.
Txai Wieser
 
Sucesso e derrota na Arquitetura Agile
Sucesso e derrota na Arquitetura AgileSucesso e derrota na Arquitetura Agile
Sucesso e derrota na Arquitetura Agile
Sérgio Giraldo
 
TDC2016SP - Dinâmica e Facilitações
TDC2016SP - Dinâmica e FacilitaçõesTDC2016SP - Dinâmica e Facilitações
TDC2016SP - Dinâmica e Facilitações
tdc-globalcode
 
TDC2016SP - Trilha Node.Js
TDC2016SP - Trilha Node.JsTDC2016SP - Trilha Node.Js
TDC2016SP - Trilha Node.Js
tdc-globalcode
 
TDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQLTDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQL
tdc-globalcode
 
TDC2016SP - Trilha Mobile
TDC2016SP - Trilha MobileTDC2016SP - Trilha Mobile
TDC2016SP - Trilha Mobile
tdc-globalcode
 
TDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQLTDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQL
tdc-globalcode
 
TDC2016SP - Trilha Node.Js
TDC2016SP - Trilha Node.JsTDC2016SP - Trilha Node.Js
TDC2016SP - Trilha Node.Js
tdc-globalcode
 
TDC2016SP - Trilha DevOps Java
TDC2016SP - Trilha DevOps JavaTDC2016SP - Trilha DevOps Java
TDC2016SP - Trilha DevOps Java
tdc-globalcode
 
Ad

Similar to Reactive Programming no Android (20)

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
 
Understanding reactive programming with microsoft reactive extensions
Understanding reactive programming  with microsoft reactive extensionsUnderstanding reactive programming  with microsoft reactive extensions
Understanding reactive programming with microsoft reactive extensions
Oleksandr Zhevzhyk
 
Rx workshop
Rx workshopRx workshop
Rx workshop
Ryan Riley
 
RxAndroid
RxAndroidRxAndroid
RxAndroid
Thinh Thanh
 
RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 Slides
YarikS
 
Intro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidIntro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich Android
Egor Andreevich
 
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
PROIDEA
 
Reactive programming and RxJS
Reactive programming and RxJSReactive programming and RxJS
Reactive programming and RxJS
Ravi Mone
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
Tomáš Kypta
 
Testing time and concurrency Rx
Testing time and concurrency RxTesting time and concurrency Rx
Testing time and concurrency Rx
Tamir Dresher
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
NexThoughts Technologies
 
Rxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJavaRxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJava
Kros Huang
 
Rx for Android & iOS by Harin Trivedi
Rx for Android & iOS  by Harin TrivediRx for Android & iOS  by Harin Trivedi
Rx for Android & iOS by Harin Trivedi
harintrivedi
 
RxJava@Android
RxJava@AndroidRxJava@Android
RxJava@Android
Maxim Volgin
 
RxJava for Android - GDG DevFest Ukraine 2015
RxJava for Android - GDG DevFest Ukraine 2015RxJava for Android - GDG DevFest Ukraine 2015
RxJava for Android - GDG DevFest Ukraine 2015
Constantine Mars
 
Rx java in action
Rx java in actionRx java in action
Rx java in action
Pratama Nur Wijaya
 
GDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokesGDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokes
Sergey Tarasevich
 
Struts2 - 101
Struts2 - 101Struts2 - 101
Struts2 - 101
Munish Gupta
 
Reactive Java (GeeCON 2014)
Reactive Java (GeeCON 2014)Reactive Java (GeeCON 2014)
Reactive Java (GeeCON 2014)
Tomasz Kowalczewski
 
Rx java workshop
Rx java workshop Rx java workshop
Rx java workshop
Mayowa Egbewunmi
 
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
 
Understanding reactive programming with microsoft reactive extensions
Understanding reactive programming  with microsoft reactive extensionsUnderstanding reactive programming  with microsoft reactive extensions
Understanding reactive programming with microsoft reactive extensions
Oleksandr Zhevzhyk
 
RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 Slides
YarikS
 
Intro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidIntro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich Android
Egor Andreevich
 
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
PROIDEA
 
Reactive programming and RxJS
Reactive programming and RxJSReactive programming and RxJS
Reactive programming and RxJS
Ravi Mone
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
Tomáš Kypta
 
Testing time and concurrency Rx
Testing time and concurrency RxTesting time and concurrency Rx
Testing time and concurrency Rx
Tamir Dresher
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
NexThoughts Technologies
 
Rxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJavaRxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJava
Kros Huang
 
Rx for Android & iOS by Harin Trivedi
Rx for Android & iOS  by Harin TrivediRx for Android & iOS  by Harin Trivedi
Rx for Android & iOS by Harin Trivedi
harintrivedi
 
RxJava for Android - GDG DevFest Ukraine 2015
RxJava for Android - GDG DevFest Ukraine 2015RxJava for Android - GDG DevFest Ukraine 2015
RxJava for Android - GDG DevFest Ukraine 2015
Constantine Mars
 
GDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokesGDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokes
Sergey Tarasevich
 
Ad

Recently uploaded (20)

HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
Connect and Protect: Networks and Network Security
Connect and Protect: Networks and Network SecurityConnect and Protect: Networks and Network Security
Connect and Protect: Networks and Network Security
VICTOR MAESTRE RAMIREZ
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
Connect and Protect: Networks and Network Security
Connect and Protect: Networks and Network SecurityConnect and Protect: Networks and Network Security
Connect and Protect: Networks and Network Security
VICTOR MAESTRE RAMIREZ
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 

Reactive Programming no Android

  • 1. 11 REACTIVE PROGRAMMING NO ANDROID Guilherme Branco Software Engineer Guilherme Pereira Branco @guipbranco
  • 2. 22 REACTIVE PROGRAMMING NO ANDROID Guilherme Branco Software Engineer Guilherme Pereira Branco @guipbranco
  • 3. Reactive Programming é do balacobaco! Quem não usa está por fora, meu! Sou deveras experiente em RxJava!
  • 6. 66 Reactive Programming | O Que é? • Pull x Push: Ao invés de pedir algo e esperar, o desenvolvedor simplesmente pede por algo e é notificado quando o resultado estiver disponível. • Paradigma baseado no conceito de fluxo de dados assíncrono. • Mais flexível. O Desenvolvedor ignora se os dados chegam de forma síncrona ou assíncrona. O código simplesmente funciona. • Fontes de dados podem ser combinadas e não aninhadas, afastando o desenvolvedor do “callback hell”
  • 7. 77 Observable Observer Emite item1 item2 item3 Manipula item 1 Manipula item 2 Manipula item 3 onNext(item1) onNext(item2) onNext(item3) Itens acabaram onCompleted() completar Ops! Erro… onError(error) Trata erro Reactive Programming | Fluxo
  • 9. 99 Anatomia | Principal Construção Observable.from(lectureService.getLectures()) 1. Observable .subcribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) 3. Schedulers .subscribe(getObserver()) 2. Observer
  • 10. 1010 public interface LectureService { List<Lecture> getLectures(); } Anatomia | Principal Construção Observable.from(lectureService.getLectures()) 1. Observable
  • 11. 1111 Anatomia | Principal Construção Observable.from(lectureService.getLectures()) 1. Observable .subcribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) 3. Schedulers .subscribe(getObserver()) 2. Observer
  • 12. 1212 Anatomia | Observer / Subscriber private Observer<Lecture> getObserver(){ return new Observer<Lecture>() { @Override public void onCompleted() { Log.e(TAG, "onCompleted"); } @Override public void onError(Throwable e) { Log.e(TAG, "onError: " + e.getMessage()); } @Override public void onNext(Lecture lecture){ Log.e(TAG, "onNext"); } }); .subscribe(getObserver()) 2. Observer
  • 13. 1313 Anatomia | Principal Construção Observable.from(lectureService.getLectures()) 1. Observable .subcribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) 3. Schedulers .subscribe(getObserver()) 2. Observer ObserverObservable = 4. Subscription
  • 14. 1414 Anatomia | Principal Construção .subcribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(getObserver()) Observable<Lecture> observable = Observable.from(lectureService.getLectures()) ; observableSubscription subscription = 1. subscription.unsubscribe() 2. CompositeSubscription compSubscription; compSubscription.add(subscription); 3. compSubscription.unsubscribe()
  • 16. 1616 public interface LectureService { List<Lecture> getLectures(); } Exemplo | AsyncTask
  • 17. 1717 new LectureAsyncTask().execute(); private class LectureAsyncTask extends AsyncTask<String, Void, List<Lecture>>{ @Override protected void onPreExecute() { showLoading(); } @Override protected List<Lecture> doInBackground(String... params){ return lectureService.getLectures(); } @Override protected void onPostExecute(List<Lecture> lectures){ hideLoading(); renderItems(lectures); } } Anatomia | AsyncTask -> Reactive
  • 18. 1818 new LectureAsyncTask().execute(); private class LectureAsyncTask extends AsyncTask<String, Void, List<Lecture>>{ @Override protected void onPreExecute() { showLoading(); } @Override protected List<Lecture> doInBackground(String... params){ return lectureService.getLectures(); } @Override protected void onPostExecute(List<Lecture> lectures){ hideLoading(); renderItems(lectures); } } Anatomia | AsyncTask -> Reactive Observable.from(lectureService.getLectures()) .doOnSubscribe(showLoading()) .subscribeOn(Schedulers.io()) .toList()
  • 19. 1919 Anatomia | AsyncTask -> Reactive Observable.from(lectureService.getLectures()) .doOnSubscribe(showLoading()) .subscribeOn(Schedulers.io()) .toList()
  • 20. 2020 new LectureAsyncTask().execute(); private class LectureAsyncTask extends AsyncTask<String, Void, List<Lecture>>{ @Override protected void onPreExecute() { showLoading(); } @Override protected List<Lecture> doInBackground(String... params){ return lectureService.getLectures(); } @Override protected void onPostExecute(List<Lecture> lectures){ hideLoading(); renderItems(lectures); } } Anatomia | AsyncTask -> Reactive Observable.from(lectureService.getLectures()) .doOnSubscribe(showLoading()) .subscribeOn(Schedulers.io()) .subscribe( new Subscriber<List<Lecture>>() { @Override public void onCompleted() { hideLoading(); } @Override public void onError(Throwable e) { Log.e(TAG, "onError: " + e.getMessage()); } @Override public void onNext(List<Lecture> lectures){ renderItems(lectures); } }); .toList()
  • 21. 2121 Anatomia | AsyncTask -> Reactive .subscribe( new Subscriber<List<Lecture>>() { @Override public void onCompleted() { hideLoading(); } @Override public void onError(Throwable e) { Log.e(TAG, "onError: " + e.getMessage()); } @Override public void onNext(List<Lecture> lectures){ renderItems(lectures); } });
  • 22. 2222 new LectureAsyncTask().execute(); private class LectureAsyncTask extends AsyncTask<String, Void, List<Lecture>>{ @Override protected void onPreExecute() { showLoading(); } @Override protected List<Lecture> doInBackground(String... params){ return lectureService.getLectures(); } @Override protected void onPostExecute(List<Lecture> lectures){ hideLoading(); renderItems(lectures); } } Anatomia | AsyncTask -> Reactive .subscribe( new Subscriber<List<Lecture>>() { @Override public void onCompleted() { hideLoading(); } @Override public void onError(Throwable e) { Log.e(TAG, "onError: " + e.getMessage()); } @Override public void onNext(List<Lecture> lectures){ renderItems(lectures); } }); Observable.from(lectureService.getLectures()) .doOnSubscribe(showLoading()) .subscribeOn(Schedulers.io()) .toList()
  • 23. 2323 Exemplo | AsyncTask -> Reactive android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
  • 24. 2424 new LectureAsyncTask().execute(); private class LectureAsyncTask extends AsyncTask<String, Void, List<Lecture>>{ @Override protected void onPreExecute() { showLoading(); } @Override protected List<Lecture> doInBackground(String... params){ return lectureService.getLectures(); } @Override protected void onPostExecute(List<Lecture> lectures){ hideLoading(); renderItems(lectures); } } Exemplo | AsyncTask -> Reactive .subscribe( new Subscriber<List<Lecture>>() { @Override public void onCompleted() { hideLoading(); } @Override public void onError(Throwable e) { Log.e(TAG, "onError: " + e.getMessage()); } @Override public void onNext(List<Lecture> lectures){ renderItems(lectures); } }); .toList() Observable.from(lectureService.getLectures()) .doOnSubscribe(showLoading()) .subscribeOn(Schedulers.io())
  • 25. 2525 Exemplo | AsyncTask -> Reactive .subscribe( new Subscriber<List<Lecture>>() { @Override public void onCompleted() { hideLoading(); } @Override public void onError(Throwable e) { Log.e(TAG, "onError: " + e.getMessage()); } @Override public void onNext(List<Lecture> lectures){ renderItems(lectures); } }); .observeOn(AndroidSchedulers.mainThread()) Observable.from(lectureService.getLectures()) .doOnSubscribe(showLoading()) .subscribeOn(Schedulers.io()) .toList()
  • 26. 2626 Exemplo | RxJava .subscribe(new Subscriber(){…}); .observeOn(AndroidSchedulers.mainThread()) Observable.from(lectureService.getLectures()) .doOnSubscribe(showLoading()) .subscribeOn(Schedulers.io()) .toList()
  • 29. 2929 Operator | Filter .filter(new Func1<Lecture, Boolean>() { @Override public Boolean call(Lecture lecture) { return lecture.getDay().equalsIgnoreCase(day); } }) .subscribe(new Subscriber(){…}); .observeOn(AndroidSchedulers.mainThread()) Observable.from(lectureService.getLectures()) .doOnSubscribe(showLoading()) .subscribeOn(Schedulers.io()) .toList()
  • 32. 3232 Observable<Lecture> observable = getLectures(); .map(new Func1<Lecture, String>() { @Override public String call(Lecture lecture) { return lecture.getDay(); } }) // Observable<String> .cast(CharSequence.class) // Observable<CharSequence> Operator | Map, Cast, Distinct… .distinct() // Mesmo Observable sem dados repetidos .toList() // Observable<List<CharSequence>> .subscribe(new Subscriber(){…}); observable
  • 33. 3333 Reactive Programming | Links https://github.com/ReactiveX/RxJava https://www.packtpub.com/application-development/rxjava-essentials http://rxmarbles.com
  • 35. OBRIGADO. Big Brains Wanted Join our team! Go to arctouch.com/brjobs Visit our booth to win an Apple Watch.

Editor's Notes

  • #6: 1 min
  • #7: Reactive Programming is a programming paradigm based on concept of an asynchronous data flow. Like a river: it can be observed, filtered, manipulated, or merged with a second flow to create a new flow for a new consumer. nstead of asking for a result and waiting, the developer simply asks for result and gets notified when result is available. Clearly more flexible, because from a logical and practical point of view, the developer can simply ignore if the data he needs comes sync or async, his code will still work.
  • #8: Functional reactive programming idea from late 90s inspired Erik Meijer. Rx is a reactive extension for .NET which provides an easy way to create async, event-driven programs using Observables sequences. Model a data stream using Observables, query and manage concurrency using Schedulers. Instead of asking for a result and waiting, the developer simply asks for result and gets notified when result is available. Clearly more flexible, because from a logical and practical point of view, the developer can simply ignore if the data he needs comes sync or async, his code will still work.
  • #10: 5min
  • #11: Behavioral pattern and ir provides a way to bind objects in a one-to-many dependency.: when one object changes, all the objects depending on it are notified and updated automatically. RxJava Observables can be composed instead of nested, saving the developer from the callback hell.
  • #13: Clear sequence of events that are going to happen. For every event the developer provides a reaction. Three missing abilities: The producer can now signal that there is no more data available: onCompleted() event. The producer can now signal that an error occurred.
  • #14: It adds three
  • #15: 10min