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
Introduction of ReactiveX
Search
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
620
実際のアプリ開発で使ったRxを紹介 #RxJaNight
bl0lia
5
1k
ApplivにRealmを導入した話
bl0lia
1
1.2k
Other Decks in Programming
See All in Programming
Jetpack Compose メカニズム
skydoves
0
450
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
120
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
150
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
230
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
450
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.8k
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
310
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
7.6k
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
550
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
1
280
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
620
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Speed Design
sergeychernyshev
33
2.1k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.9k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
240
Visualization
eitanlees
152
17k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
580
Embracing the Ebb and Flow
colly
88
5.2k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
430
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()