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
実際のアプリ開発で使ったRxを紹介 #RxJaNight
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yuki Funakoshi
February 25, 2016
Programming
1k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
実際のアプリ開発で使ったRxを紹介 #RxJaNight
Yuki Funakoshi
February 25, 2016
More Decks by Yuki Funakoshi
See All by Yuki Funakoshi
Android Emulator 2.0
bl0lia
0
600
Introduction of ReactiveX
bl0lia
0
150
ApplivにRealmを導入した話
bl0lia
1
1.2k
Other Decks in Programming
See All in Programming
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
15
7.2k
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
190
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
190
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
360
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.4k
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
200
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
110
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
130
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
230
Inside Stream API
skrb
1
790
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
490
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
300
Speed Design
sergeychernyshev
33
1.9k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Bash Introduction
62gerente
615
220k
The Cult of Friendly URLs
andyhume
79
6.9k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
280
Ethics towards AI in product and experience design
skipperchong
2
320
Transcript
㹋ꥷך،فٔ涪ד ⢪3Y稱➜ #RxJaNight
ࣗݾհ • Yuki Funakoshi (@bl_lia) • NYLE Inc. • Android
/ iOS Engineer
جຊతͳ
ඇಉظॲཧͷίϯϙʔωϯτԽ Πϕϯτϕʔεϓϩάϥϛϯά
Observable Subscriber subscribe send event
Observable Observable Observable Subscriber filter map send event operator
Observable Observable Subscriber send event send event
None
https://github.com/android10/Android-CleanArchitecture
public interface AppSearchRepository { Observable<List<SearchResult>> search(String query); Observable<List<SearchResult>> searchMore(String query);
Observable<List<Suggest>> suggest(String query); }
Case 1 Observableͷ࡞
• just(T value) • create(Observable.OnSubscribe<T> f)
http://reactivex.io/documentation/operators/just.html
Observable.just(sharedPreferences.getBoolean(KEY_ENABLE, true));
http://reactivex.io/documentation/operators/create.html
Observable.create(subscriber -> { final Gson gson = new Gson(); final
String alertJson = sharedPreferences.getString(KEY_ALERT, ""); final Alert alert = gson.fromJson(alertJson, Alert.class); subscriber.onNext(alert); subscriber.onCompleted(); });
Case 2 ॲཧͷՃ
• filter(Func1) • startWith(Iterable) / startWith(T)
http://reactivex.io/documentation/operators/filter.html
Ϧετ͔Βআ֎ ɾγεςϜΞϓϦ ɾApplivΞϓϦ
Observable.from(packageManager.getInstalledApplications(PackageManager.GET_META_DATA)) .filter(app -> { if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM)
return false; if (applicationInfo.packageName.equals(application.getPackageName())) return false; return true; }) .toList();
http://reactivex.io/documentation/operators/startwith.html
ةحف
recommendService.like(recommendId, isLike) .map(response -> response.recommend) .startWith(() -> { return fakeRecommend;
});
Case 3 API͔Βͷσʔλऔಘ
• Retrofit • map(Func1) • doOnNext(Action1)
{ "result": true, "items": [{ "id": "aaaaaa", "title": "Item A"
},{ "id": "bbbbbb", "title": "Item B" }] }
None
dependencies { compile 'io.reactivex:rxjava:1.1.1' compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2' }
class Item { public final String id; public final String
title; public Item(String id, String title) { this.id = id; this.title = title; } } class ItemResponse { public final boolean result; public final List<Item> items; public ItemResponse(boolean result, List<Item> items) { this.result = result; this.items = items; } } interface ItemService { @GET("/items") Observable<ItemResponse> items(); }
public void getItems() { final Retrofit retrofit = new Retrofit.Builder().baseUrl("http://hogehoge.com")
.addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build(); final ItemService service = retrofit.create(ItemService.class); service.items() .map(itemResponse -> itemResponse.items); }
http://reactivex.io/documentation/operators/map.html
Factory Class cached? Disk Data Store API Data Store Disk
Data Cache API
Factory Class cached? Disk Data Store API Data Store Disk
Data Cache API
Factory Class cached? Disk Data Store API Data Store Disk
Data Cache API
Factory Class cached? Disk Data Store API Data Store Disk
Data Cache API
http://reactivex.io/documentation/operators/do.html
interface ItemCache { void addItems(List<Item> items); } public void getItems(ItemCache
cache) { final Retrofit retrofit = new Retrofit.Builder().baseUrl("http://hogehoge.com") .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build(); final ItemService service = retrofit.create(ItemService.class); service.items() .map(itemResponse -> itemResponse.items) .doOnNext(items -> cache.addItems(items)); }
ך➭
• Τϥʔॲཧܥ • subscriber.onError(Throwable) • OnErrorThrowable.from(Throwable) • Observable.onError(Throwable) • onErrorResumeNext(Observable)
• onErrorReturn(Func1)
• ςετ·ΘΓ • TestSubscriber<T> • assertCompleted() / assertNotCompleted() • assertValue(T
value) / assertNoValues() • assertError(java.lang.Throwable throwable) / assertNoErrors()