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
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction of ReactiveX
Yuki Funakoshi
February 08, 2016
Transcript
23 slides
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()
More Decks by Yuki Funakoshi
See All by Yuki Funakoshi
Android Emulator 2.0
bl0lia
0
630
実際のアプリ開発で使ったRxを紹介 #RxJaNight
bl0lia
5
1k
ApplivにRealmを導入した話
bl0lia
1
1.2k
Other Decks in Programming
See All in Programming
マルチプロダクトSaaSの アプリ一覧を速くする——複数プロダクトにまたがる「権限行脚」を減らすまで #techramen26conf
mktakuya
1
190
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
270
疎結合とは何か?ソフトウェア設計における結合バランスについて考える #phpcon_niigata
kajitack
2
420
SODA - FACT BOOK(JP)
sodainc
1
40k
AI Augmentation Techniques with Liberty
ivargrimstad
1
560
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
150
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
300
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
390
はじめてのKubernetesコントリビューション
nasa9084
0
320
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
110
Spec-driven Development with AI
simas
PRO
0
2.3k
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
340
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.7k
Test your architecture with Archunit
thirion
2
2.5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
ラッコキーワード サービス紹介資料
rakko
5
6M
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
750
Designing for humans not robots
tammielis
254
26k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Navigating Weather and Climate Data
rabernat
0
600
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.5k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
350