Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Reactive way on Android
Search
WeRockStar
August 30, 2019
Programming
41
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Reactive way on Android
Presentation at ReactiveX meetup first in Bangkok, Thailand
WeRockStar
August 30, 2019
Transcript
51 slides
@werockstar @werockstar Kotchaphan Muangsan Software Developer @ODDS
@werockstar Interested - Fundamental - OOP, FP, RP - Design
Pattern, Refactoring - Software Design
medium.com/@werockstar
None
None
Reactively way on Android @werockstar
@werockstar The Land of Reactive
@werockstar
@werockstar Before we start I gonna sharing some story about
Rx on Mobile Development
@werockstar We know the first implementation of Rx is Rx.NET
@werockstar And which is the first mobile OS uses Rx?
@werockstar And Android RxJava RxKotlin RxBinding Agera iOS RxSwift ReactiveCocoa
ReactiveSwift
Solve the same problem with Rx
@werockstar Zero to One Basic Rx on UI
@werockstar 'io.reactivex.rxjava2:rxjava:2.2.11' 'io.reactivex.rxjava2:rxkotlin:2.4.0' 'com.jakewharton.rxbinding3:rxbinding-core:3.0.0'
@werockstar click click click click
@werockstar click click click click click Time
@werockstar button.clicks() .subscribe() click click click click Button as an
producer(observable) Emitter of event() value over time Time
@werockstar button.clicks() .subscribe( { data -> println(data) }, { error
-> } ) Observer or subscriber Observer doesn't know anything about the data come from and when, or how many times
@werockstar button.clicks() .subscribe( { data -> println(data) }, { error
-> } ) Why <- Producer (Observable) <- Observer
@werockstar .subscribe( { data -> println(data) }, { error ->
} ) button.clicks() Why Decoupling the relationship Know little about each other
@werockstar click click click click Duplicate pages?
@werockstar button.clicks() .debounce(150, MILLISECONDS) .subscribe()
@werockstar click click click debounce(150, MILLISECONDS) 150 ms 150 ms
150 ms ✅
@werockstar Auto search editText.afterTextChangeEvents() .debounce(150, MILLISECONDS) .subscribe()
@werockstar editText.afterTextChangeEvents() .debounce(150, MILLISECONDS) .subscribe() A A B “A” and
“A” are duplicates?
@werockstar editText.afterTextChangeEvents() .debounce(150, MILLISECONDS) .distinctUntilChanged() ✅ .subscribe() A A B
“A” and “A” are duplicates?
@werockstar Sample Window Buffer Throttle
@werockstar ————
@werockstar
@werockstar A A B API?
@werockstar editText.afterTextChangeEvents() .debounce(200, MILLISECONDS) .distinctUntilChanged() .flatMap { api.getResult(it) } .subscribe()
A A B
@werockstar A A B API
@werockstar
@werockstar editText.afterTextChangeEvents() .debounce(200, MILLISECONDS) .distinctUntilChanged() .map { it.editable.toString() } .switchMap
{ api.getResult(it) } .subscribe() A A B
@werockstar Retry Patterns
@werockstar editText.afterTextChangeEvents() .debounce(200, MILLISECONDS) .distinctUntilChanged() .map { it.editable.toString() } .switchMap
{ api.getResult(it) } .subscribe() A A B ก้าวแรกไม่เป็นไร ก้าวต่อไปไฟเริ่มไหม้ getResult
@werockstar editText.afterTextChangeEvents() .debounce(200, TimeUnit.MILLISECONDS) .distinctUntilChanged() .map { it.editable.toString() } .switchMap
{ api.getResult(it) .retry(2) } .subscribe() A A B ✅
@werockstar But We shouldn't use retry in every situation
@werockstar editText.afterTextChangeEvents() .debounce(200, TimeUnit.MILLISECONDS) .distinctUntilChanged() .map { it.editable.toString() } .switchMap
{ api.getResult(it) .retry { attempt, throwable -> throwable is TimeoutException && attempt <= 2 } }.subscribe()
@werockstar editText.afterTextChangeEvents() .debounce(200, TimeUnit.MILLISECONDS) .distinctUntilChanged() .map { it.editable.toString() } .switchMap
{ api.getResult(it) .retry { attempt, throwable -> throwable is TimeoutException && attempt <= 2 } }.subscribe() .onErrorReturnItem("WeRockStar") ✅
@werockstar Reactively on precondition
@werockstar editText.afterTextChangeEvents() ... .switchMap { api.getResult(it) .retryWhen { it.flatMap {
throwable -> when (throwable.code()) { 401 -> api.getSomeToken("refresh_token") else -> Observable.error(throwable) } } } }.subscribe() 1 2
@werockstar And finally Delay error notification
@werockstar Observable.mergeDelayError( api.delete1(), api.delete2(), api.delete3() ).subscribe()
@werockstar And then
@werockstar Build in solutions
@werockstar Complex solution for complex problem
@werockstar Reactive Data Flow Back Pressure Flow Control Subject Push/Pull
Hot/Cold Messaging Responsive Elastic Publish/Subscribe Resilience Stream
@werockstar 80 Years of Life 5 ปีหมดไปการลองใช้ Rx 10 ปีหมดไปกับ
Observable 25 ปีหมดไปกับ FlatMap ส่วน 40 ปีที่เหลือหมดไปกับการทำความเข้าใจ และอธิบาย Reactive
@werockstar Questions and Answers @werockstar Thank you
More Decks by WeRockStar
See All by WeRockStar
Software Design & Architecture on my mind
werockstar
0
190
Kotlin in 2 Days
werockstar
0
45
Kotlin Testing for Android
werockstar
1
83
Modern Android Development
werockstar
0
120
Disrupt Innovation
werockstar
0
55
Kotlin 101#1
werockstar
0
110
Android Reactive Programming
werockstar
0
160
Mobile Automate Testing
werockstar
0
74
Other Decks in Programming
See All in Programming
R言語プログラミング
profjoesuzuki
0
110
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
17
9.6k
Skills Are the New npm [AAIF Bengaluru, Nov 2026]
shivamsaraswat
0
140
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
350
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
450
祈るテストから、探索するテストへ 〜Lincheckではじめる並行処理テスト〜
yyh_gl
0
430
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
320
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
270
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1.1k
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
240
眠らない開発チームの作り方
biwakonbu
0
160
Featured
See All Featured
Unsuck your backbone
ammeep
672
58k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
530
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
410
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
580
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.9k
How to build a perfect <img>
jonoalderson
1
6.3k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
700
Deep Space Network (abreviated)
tonyrice
0
430
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
340
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
Building a Scalable Design System with Sketch
lauravandoore
464
34k