Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
RxJava での Observable のつくりかた
Pine Mizune
November 18, 2015
Programming
0
120
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
390
C++ 製グラフィックライブラリ Skia の紹介 / Introduction to the graphics library Skia written by C++
pine
0
830
asyncio + aiohttp で作るウェブサービス / How to develop a web service with asyncio and aiohttp
pine
0
420
Lerna による明示的疎結合アーキテクチャ
pine
1
520
CircleCI 2.0 x JavaScript
pine
3
460
Perl 卒業式
pine
0
270
Android Studio の気になる warnings を抑制する方法まとめ
pine
0
380
Emoji Generator meets Browser Extensions
pine
1
2.7k
近年の OSS 開発における CI 選択のベストプラクティス
pine
3
4.4k
Other Decks in Programming
See All in Programming
Licences open source : entre guerre de clochers et radicalité
pylapp
2
380
脱オブジェクト指向講座(5分LT資料)
kishida
8
11k
byte列のbit表現を得るencodingライブラリ作った
convto
1
210
よりUXに近いSLI・SLOの運用による可用性の再設計
kazumanagano
3
1.1k
[RailsConf 2022] The pitfalls of realtime-ification
palkan
0
370
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
4
660
httputil.ReverseProxy でもリトライがしたい
toga4
1
140
Unboxing Rails 7
claudiob
1
120
Update from the Elixir team - 2022
whatyouhide
0
200
mrubyを1300円のボードで動かそう
yuuu
0
190
マイクロインタラクション入門〜ディテイルにこだわるエンジニアリング〜
swimmyxox
0
120
熊でもわかるCI/CD/モダンインフラVol1:用語を覚えよう編
srockstyle
0
110
Featured
See All Featured
The Most Common Mistakes in Cover Letters
jrick
PRO
4
24k
GraphQLの誤解/rethinking-graphql
sonatard
24
6.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
15
920
Build your cross-platform service in a week with App Engine
jlugia
219
17k
Code Reviewing Like a Champion
maltzj
506
37k
A designer walks into a library…
pauljervisheath
196
16k
Designing for Performance
lara
596
63k
Building Flexible Design Systems
yeseniaperezcruz
310
33k
Three Pipe Problems
jasonvnalue
89
8.6k
The Invisible Customer
myddelton
110
11k
Building Your Own Lightsaber
phodgson
94
4.6k
Build The Right Thing And Hit Your Dates
maggiecrowley
19
1.2k
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