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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
The NotImplementedError Problem in Ruby
koic
1
950
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
200
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
220
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
840
dRuby over BLE
makicamel
2
390
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
8.3k
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.5k
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
13
6.3k
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.4k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
370
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
260
GraphQLとの向き合い方2022年版
quramy
50
15k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
620
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
440
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
640
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
BBQ
matthewcrist
89
10k
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()