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
Introduction of ReactiveX
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yuki Funakoshi
February 08, 2016
Programming
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction of ReactiveX
Yuki Funakoshi
February 08, 2016
More Decks by Yuki Funakoshi
See All by Yuki Funakoshi
Android Emulator 2.0
bl0lia
0
600
実際のアプリ開発で使ったRxを紹介 #RxJaNight
bl0lia
5
1k
ApplivにRealmを導入した話
bl0lia
1
1.2k
Other Decks in Programming
See All in Programming
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
320
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
230
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
200
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
Agentic UI
manfredsteyer
PRO
0
200
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
120
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.5k
Datadog LLM Observabilityで実現する 安全なLLM Usage 管理
3150
0
120
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
190
Creating Composable Callables in Contemporary C++
rollbear
0
170
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
14
5.9k
Featured
See All Featured
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
170
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Building Applications with DynamoDB
mza
96
7.1k
The World Runs on Bad Software
bkeepers
PRO
72
12k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
The Spectacular Lies of Maps
axbom
PRO
1
820
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
250
Embracing the Ebb and Flow
colly
88
5.1k
The Curious Case for Waylosing
cassininazir
1
400
Ethics towards AI in product and experience design
skipperchong
2
320
Transcript
Introduction Yuki Funakoshi (@bl_lia) NYLE Inc. Android / iOS Engineer
Appliv use Android Clean Architecture use Dependency Injection use Realm
use Kotlin … and use RxJava!
Introduction of RxJava
Observable.from(arrayOf( "Introduction", "Appliv App for Android", "Basic of ReactiveX", “ReactiveX
with Appliv" )).subscribe{ title -> present(title) };
Do you know ReactveX ?
ReactiveX is… Composing asynchronous Event-based programs
Observable Subscriber Subscribe Send Event Async
Observable Subscriber Observable Observable Filter Map Send Event
Observable Observable Subscriber Send Event Send Event
Observable.from(arrayOf(1,2,3,4,5,6,7,8,9,10)) .filter { it % 2 == 0 } .subscribe
{ println(it) } 2 4 6 8 10
val a = Observable.from(arrayOf(1,2,3,4,5)) val b = Observable.from(arrayOf(6,7,8,9,10)) Observable.merge(a, b)
.filter { it % 2 == 0 } .subscribe { println(it) } 2 4 6 8 10
val a = Observable.from(arrayOf(1,2,3,4,5)) val b = Observable.from(arrayOf(6,7,8,9,10)) Observable.merge(a, b)
.filter { it % 2 == 0 } .subscribeOn(Schedulers.newThread()) .subscribe { println(it) } 2 4 6 8 10
val a = Observable.create<Int> { subscriber -> subscriber.onNext(2); subscriber.onCompleted(); }
val b = Observable.from(arrayOf(6,7,8,9,10)) Observable.merge(a, b) .filter { it % 2 == 0 } .subscribe { println(it) } 2 6 8 10
data class Item(val id: String, val title: String) interface ItemService
{ @GET("/api/v2/items") fun items(): Observable<List<Item>> } fun api() { val retrofit = Retrofit.Builder() .baseUrl("http://qiita.com") .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build(); val service = retrofit.create(ItemService::class.java) service.items().subscribe { it.map { println(it.title) } } } https://gist.github.com/bl-lia/49130ad9d9730c826d02
Cache Control Factory Class cached? Disk Data Store API Data
Store Disk Data Cache API
interface ItemDataStore { fun items(): Observable<List<Item>> } // Singleton Class
object ItemCache : ItemDataStore { override fun items(): Observable<List<Item>> { // Return cached items } fun reset(newItemList: List<Item>) { // Replace cached items } fun isCached(): Boolean { // Cache data exists? } } class ItemApi(cache: ItemCache) : ItemDataStore { val cache = cache override fun items(): Observable<List<Item>> { val retrofit = Retrofit.Builder()...build() val service = retrofit.create(ItemService::class.java) return service.items().doOnNext { cache.reset(it) } } } https://gist.github.com/bl-lia/23023d968ab884708f30
class ItemStoreFactory { val cache = ItemCache fun create(): ItemDataStore
{ if (cache.isCached()) { return cache } return ItemApi(cache) } } fun main(args : Array<String>) { ItemStoreFactory().create().items() } https://gist.github.com/bl-lia/23023d968ab884708f30
UI Control with RxJava
None
RxTextView.textChanges(textView) .debounce(1, TimeUnit.SECONDS) .subscribe { search(it) }
https://github.com/bl-lia/RxFb
RxLoginManager.from(loginManager) .logInWithReadPermissions(callbackManager, fragment, permissions) .flatMap { return RxGraphRequest.newMeRequest(accessToken, params) }
.subscribe { doAnything() }
onCompleted()