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
150
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
820
C++ 製グラフィックライブラリ Skia の紹介 / Introduction to the graphics library Skia written by C++
pine
0
1.8k
asyncio + aiohttp で作るウェブサービス / How to develop a web service with asyncio and aiohttp
pine
0
670
Lerna による明示的疎結合アーキテクチャ
pine
1
640
CircleCI 2.0 x JavaScript
pine
3
550
Perl 卒業式
pine
0
340
Android Studio の気になる warnings を抑制する方法まとめ
pine
0
500
Emoji Generator meets Browser Extensions
pine
1
3k
近年の OSS 開発における CI 選択のベストプラクティス
pine
3
4.5k
Other Decks in Programming
See All in Programming
品質ワークショップをやってみた
nealle
0
640
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
5.4k
bootcamp2025_バックエンド研修_WebAPIサーバ作成.pdf
geniee_inc
0
130
contribution to astral-sh/uv
shunsock
0
540
O Que É e Como Funciona o PHP-FPM?
marcelgsantos
0
200
Reactive Thinking with Signals and the Resource API
manfredsteyer
PRO
0
110
技術的負債の正体を知って向き合う
irof
0
260
EMこそClaude Codeでコード調査しよう
shibayu36
0
430
Google Opalで使える37のライブラリ
mickey_kubo
3
150
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
260
Go言語はstack overflowの夢を見るか?
logica0419
0
610
Six and a half ridiculous things to do with Quarkus
hollycummins
0
210
Featured
See All Featured
Producing Creativity
orderedlist
PRO
347
40k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Navigating Team Friction
lara
190
15k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Leading Effective Engineering Teams in the AI Era
addyosmani
7
640
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
10
890
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Why Our Code Smells
bkeepers
PRO
340
57k
The Cult of Friendly URLs
andyhume
79
6.6k
Docker and Python
trallard
46
3.6k
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