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
780
C++ 製グラフィックライブラリ Skia の紹介 / Introduction to the graphics library Skia written by C++
pine
0
1.7k
asyncio + aiohttp で作るウェブサービス / How to develop a web service with asyncio and aiohttp
pine
0
660
Lerna による明示的疎結合アーキテクチャ
pine
1
630
CircleCI 2.0 x JavaScript
pine
3
540
Perl 卒業式
pine
0
330
Android Studio の気になる warnings を抑制する方法まとめ
pine
0
490
Emoji Generator meets Browser Extensions
pine
1
2.9k
近年の OSS 開発における CI 選択のベストプラクティス
pine
3
4.5k
Other Decks in Programming
See All in Programming
PostgreSQLのRow Level SecurityをPHPのORMで扱う Eloquent vs Doctrine #phpcon #track2
77web
2
250
レガシーシステムの機能調査・開発におけるAI利活用
takuya_ohtonari
0
610
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
440
Enterprise Web App. Development (2): Version Control Tool Training Ver. 5.1
knakagawa
1
120
童醫院敏捷轉型的實踐經驗
cclai999
0
160
Select API from Kotlin Coroutine
jmatsu
1
190
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
170
データベースコネクションプール(DBCP)の変遷と理解
fujikawa8
1
270
Using AI Tools Around Software Development
inouehi
0
1.3k
A2A プロトコルを試してみる
azukiazusa1
2
1k
Is Xcode slowly dying out in 2025?
uetyo
1
180
AWS CDKの推しポイント 〜CloudFormationと比較してみた〜
akihisaikeda
3
300
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Statistics for Hackers
jakevdp
799
220k
Bash Introduction
62gerente
614
210k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
Embracing the Ebb and Flow
colly
86
4.7k
We Have a Design System, Now What?
morganepeng
53
7.6k
The Cost Of JavaScript in 2023
addyosmani
51
8.4k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Gamification - CAS2011
davidbonilla
81
5.3k
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