Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Reactive way on Android
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
WeRockStar
August 30, 2019
Programming
0
24
Reactive way on Android
Presentation at ReactiveX meetup first in Bangkok, Thailand
WeRockStar
August 30, 2019
Tweet
Share
More Decks by WeRockStar
See All by WeRockStar
Software Design & Architecture on my mind
werockstar
0
160
Kotlin in 2 Days
werockstar
0
31
Kotlin Testing for Android
werockstar
1
66
Modern Android Development
werockstar
0
110
Disrupt Innovation
werockstar
0
40
Kotlin 101#1
werockstar
0
99
Android Reactive Programming
werockstar
0
140
Mobile Automate Testing
werockstar
0
60
Other Decks in Programming
See All in Programming
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2k
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
Grafana:建立系統全知視角的捷徑
blueswen
0
330
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.8k
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.3k
Patterns of Patterns
denyspoltorak
0
1.4k
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
110
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
970
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
180
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
4
330
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
450
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
510
Featured
See All Featured
Paper Plane
katiecoart
PRO
0
46k
How STYLIGHT went responsive
nonsquared
100
6k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
Designing for Timeless Needs
cassininazir
0
130
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
130
BBQ
matthewcrist
89
10k
Transcript
@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