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
RxJava での Observable のつくりかた
Search
Pine Mizune
November 18, 2015
Programming
0
130
RxJava での Observable のつくりかた
社内 ReactiveX 勉強会での発表資料
ソースコード:
https://github.com/pine613/rxnight
Pine Mizune
November 18, 2015
Tweet
Share
More Decks by Pine Mizune
See All by Pine Mizune
多言語対応と絵文字ジェネレーター / i18n of Emoji Generator
pine
0
630
C++ 製グラフィックライブラリ Skia の紹介 / Introduction to the graphics library Skia written by C++
pine
0
1.3k
asyncio + aiohttp で作るウェブサービス / How to develop a web service with asyncio and aiohttp
pine
0
580
Lerna による明示的疎結合アーキテクチャ
pine
1
580
CircleCI 2.0 x JavaScript
pine
3
500
Perl 卒業式
pine
0
290
Android Studio の気になる warnings を抑制する方法まとめ
pine
0
450
Emoji Generator meets Browser Extensions
pine
1
2.9k
近年の OSS 開発における CI 選択のベストプラクティス
pine
3
4.5k
Other Decks in Programming
See All in Programming
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
130
使ってみよう Azure AI Document Intelligence
kosmosebi
2
300
見た目から始める生産性向上
ikumatadokoro
7
830
PHPはいつから死んでいるかの調査
chiroruxx
1
390
PostmanでAPIの動作確認が楽になった話
h455h1
0
170
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
380
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
730
HUIT新歓2024「競技プログラミング、やってみませんか?」
slephy2784
1
270
今、知っておきたい! 生成AIエージェントの世界
elith
3
350
Random\Randomizer クラスで日常のあれこれを解決しよう! / Random\Randomizer class solves familiar trouble
cocoeyes02
0
220
Ruby GitHub Packages
bkuhlmann
0
630
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
5
900
Featured
See All Featured
Thoughts on Productivity
jonyablonski
58
3.8k
Building Your Own Lightsaber
phodgson
99
5.7k
How to Ace a Technical Interview
jacobian
272
22k
Code Reviewing Like a Champion
maltzj
514
39k
Rails Girls Zürich Keynote
gr2m
91
13k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
121
39k
Embracing the Ebb and Flow
colly
80
4.1k
A better future with KSS
kneath
231
16k
Build The Right Thing And Hit Your Dates
maggiecrowley
24
2k
Building Effective Engineering Teams - LeadDev
addyosmani
28
1.8k
KATA
mclloyd
15
12k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Transcript
RxJava での Observable のつくりかた Pine Mizune
もくじ • just • empty • from • range •
repeat • create
ソースコードはこちら • Java 7 ~ • ./gradlew run • https://github.com/pine613/rxnight
just (1/2) Observable .just("yano") .subscribe(new Action1<String>() { @Override public void
call(String name) { // Hello yano System.out.println("Hello, " + name + "!"); } });
just (2/2) Observable.create(new Observable.OnSubscribe<String>() { @Override public void call(final Subscriber<?
super String> observer) { observer.onNext("yano"); observer.onCompleted(); } }).subscribe(new Action1<String>() { @Override public void call(String name) { System.out.println("Hello, " + name + "!"); // Hello yano } });
empty Observable.<String>empty().doOnCompleted(new Action0() { @Override public void call() { System.out.println("Completed");
} }).subscribe(new Action1<String>() { @Override public void call(String name) { // not performed ... System.out.println("Hello, " + name + "!"); } });
range Observable .range(1, 10) .subscribe(new Action1<Integer>() { @Override public void
call(Integer value) { System.out.println(value); // 1, 2, ..., 10 } });
range Observable.range(1, 10).map(new Func1<Integer, Integer>() { @Override public Integer call(Integer
value) { return value * 2; // 2, 4, 6, ... } }) .reduce(0, new Func2<Integer, Integer, Integer>() { // sum @Override public Integer call(Integer sum, Integer value) { return sum + value; } }).subscribe(new Action1<Integer>() { @Override public void call(Integer value) { System.out.println(value); // 110 } });
repeat (1/2) Observable .just(1) .repeat(3) .subscribe(new Action1<Integer>() { @Override public
void call(Integer value) { System.out.println(value); // 1, 1, 1 } });
repeat (2/2) Observable .from(new Boolean[]{ true, false }) .repeat(3) .subscribe(new
Action1<Boolean>() { @Override public void call(Boolean value) { System.out.println(value); // true, false, ... } });
create (1/2) Observable<Integer> random = Observable.create( new Observable.OnSubscribe<Integer>() { @Override
public void call(final Subscriber<? super Integer> observer) { Random random = new Random(); observer.onNext(random.nextInt(10)); // 0 ~ 9 observer.onCompleted(); } });
create (2/2) Observable<Integer> random = Observable.create(new Observable.OnSubscribe<Integer>() { @Override public
void call(final Subscriber<? super Integer> observer) { Random random = new Random(); observer.onNext(random.nextInt(10)); // 0 ~ 9 observer.onCompleted(); } }); random.repeat().take(10).subscribe(new Action1<Integer>() { @Override public void call(Integer value) { System.out.println(value); // 7, 0, 8, ... } });
THANKS