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
140
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
750
C++ 製グラフィックライブラリ Skia の紹介 / Introduction to the graphics library Skia written by C++
pine
0
1.6k
asyncio + aiohttp で作るウェブサービス / How to develop a web service with asyncio and aiohttp
pine
0
640
Lerna による明示的疎結合アーキテクチャ
pine
1
620
CircleCI 2.0 x JavaScript
pine
3
530
Perl 卒業式
pine
0
320
Android Studio の気になる warnings を抑制する方法まとめ
pine
0
480
Emoji Generator meets Browser Extensions
pine
1
2.9k
近年の OSS 開発における CI 選択のベストプラクティス
pine
3
4.5k
Other Decks in Programming
See All in Programming
The Clean ArchitectureがWebフロントエンドでしっくりこないのは何故か / Why The Clean Architecture does not fit with Web Frontend
twada
PRO
54
17k
バッチを作らなきゃとなったときに考えること
irof
2
550
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
8
1.5k
ABEMA iOS 大規模プロジェクトにおける段階的な技術刷新 / ABEMA iOS Technology Upgrade
akkyie
1
240
Drawing Heighway’s Dragon- Recursive Function Rewrite- From Imperative Style in Pascal 64 To Functional Style in Scala 3
philipschwarz
PRO
0
150
5分で理解する SOLID 原則 #phpcon_nagoya
shogogg
1
410
オレを救った Cline を紹介する
codehex
15
13k
Swift Testingのモチベを上げたい
stoticdev
2
200
Better Code Design in PHP
afilina
0
180
自力でTTSモデルを作った話
zgock999
0
120
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
14
4.8k
もう僕は OpenAPI を書きたくない
sgash708
6
1.9k
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Facilitating Awesome Meetings
lara
53
6.3k
GitHub's CSS Performance
jonrohan
1030
460k
YesSQL, Process and Tooling at Scale
rocio
172
14k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
What's in a price? How to price your products and services
michaelherold
244
12k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Speed Design
sergeychernyshev
28
820
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
How to train your dragon (web standard)
notwaldorf
91
5.9k
GraphQLの誤解/rethinking-graphql
sonatard
69
10k
Why Our Code Smells
bkeepers
PRO
336
57k
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