Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RxJava
Search
Douglas Kayama
August 29, 2015
Programming
5
570
RxJava
Palestra apresentada na QCon RJ 2015 e Android Dev Conference iMasters 2015
Douglas Kayama
August 29, 2015
Tweet
Share
More Decks by Douglas Kayama
See All by Douglas Kayama
TensorFlow no Android – v2
douglasdrumond
0
33
BLE
douglasdrumond
0
32
TensorFlow no Android
douglasdrumond
0
26
Firebase or Realm?
douglasdrumond
0
80
Rio Dev Day – Introdução ao Android
douglasdrumond
0
99
Google I/O
douglasdrumond
0
62
Criando apps com alto nível de qualidade (versão longa)
douglasdrumond
0
42
Criando apps com alto nível de qualidade (versão curta)
douglasdrumond
0
29
Primeiros Passos com Google Fit
douglasdrumond
0
190
Other Decks in Programming
See All in Programming
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
190
Rediscover the Console - SymfonyCon Amsterdam 2025
chalasr
2
170
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
150
SwiftUIで本格音ゲー実装してみた
hypebeans
0
420
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
850
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
840
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
360
tparseでgo testの出力を見やすくする
utgwkk
2
250
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
モデル駆動設計をやってみようワークショップ開催報告(Modeling Forum2025) / model driven design workshop report
haru860
0
270
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
1
380
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
100
Featured
See All Featured
Visualization
eitanlees
150
16k
Designing for Performance
lara
610
69k
Docker and Python
trallard
47
3.7k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
32
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
81
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
How to Ace a Technical Interview
jacobian
281
24k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Are puppies a ranking factor?
jonoalderson
0
2.3k
The Language of Interfaces
destraynor
162
25k
Into the Great Unknown - MozCon
thekraken
40
2.2k
Transcript
RxJava Douglas Drumond
[email protected]
whoami
None
Por que RxJava? Eventos de UI Eventos do domínio Concorrência
RxJava Observer pattern Iterator pattern Functional programming
Lambda
Retrolambda export JAVA_HOME=/path/java8 export JAVA7_HOME=/path/java7
Retrolambda plugins { id "me.tatarka.retrolambda" version "3.2.2" } android {
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }
Retrolambda view.setOnClickListener(new View. OnClickListener() { @Override public void onClick(final View
v) { ... } });
Retrolambda view.setOnClickListener(v -> { });
Básico Observables Subscribers Operadores
Observables Emite itens Chama onNext, onComplete ou onError Hot or
Cold
Subscriber Implementa onNext onComplete onError
Operadores flatMap filter debounce create defer etc
Criando Observable e Subscriber DEMO
Operators Subscribers reagem, não mudam Operadores transformam dados
Operators DEMO
Exemplo com UI DEMO
Mais operadores filter Ex: .filter(query -> !TextUtils.isEmpty(query))
Threads subscribeOn observeOn NewThreadScheduler HandlerThreadScheduler
Rede DEMO
Tratamento de erros Observable.create(...) .map(s -> exception(s)) .map(s -> exception2(s))
.subscribe(new Subscriber<String>() { @Override public void onNext(String s) { Log.d(TAG, s); } @Override public void onCompleted() { Log.d(TAG, "uhu!"); } @Override public void onError(Throwable e) { Log.e(TAG, "ops!"); } });
Ciclo de vida da Activity .cache .unsubscribe ao rodar .subscribe
ao restaurar Use RxLifecycle
Google Play Services https://github.com /mcharmas/Android-ReactiveLocation https://github.com /zmarkan/Reactive-PlayServices
Google Play Services ReactiveLocationProvider locationProvider = new ReactiveLocationProvider(context); locationProvider.getLastKnownLocation() .subscribe(new
Action1<Location>() { @Override public void call(Location location) { doSthImportantWithObtainedLocation(location); } });
Testes @Test public void shouldLoadTwoUsers() throw Exception { TestSubscriber<User> testSubscriber
= new TestSubscriber<>(); databaseHelper.loadUser().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertReceivedOnNext( Arrays.asList(user1, user2)) }
Testes https://github.com/ribot/assertj-rx + BlockingObservable
Testes (exemplo) assertThat(observable.toBlocking()). completes(); assertThat(observable.toBlocking()) .completes() .listOfValuesEmitted() .containsExactly("a", "b", "c");
Referências http://reactivex.io/ https://github.com/ReactiveX/RxJava/wiki /Alphabetical-List-of-Observable-Operators https://speakerdeck.com/benjchristensen https://github.com/mutexkid/rxjava-koans
Referências https://github.com/trello/RxLifecycle https://github.com/JakeWharton/RxBinding https://github.com/ReactiveX/RxAndroid/
Código https://github.com/ douglasdrumond/KnightsOfLambdaCalculus
Obrigado
Contato
[email protected]
@douglasdrumond +DouglasDrumond www.cafelinear.com
[email protected]