Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RxJSのカスタムオペレータに挑戦しよう!
Search
ponday
March 16, 2018
Programming
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RxJSのカスタムオペレータに挑戦しよう!
Angular触ろうの会 in Fukuoka #5(2018/03/16)の発表資料です。
ponday
March 16, 2018
More Decks by ponday
See All by ponday
関数型でGoFのデザインパターンやってみる
honda
1
1.7k
TypeScriptの型表現
honda
10
3.1k
Web Componentsの今
honda
1
480
これまでのReact、これからのReact
honda
0
350
Gatsbyお試し
honda
0
150
styled-components or emotion?
honda
0
730
Web ComponentsとAngular
honda
0
160
Atomic Design周りについての私見
honda
1
810
え、まだWeb Componentsを未来の技術だと思ってるの?
honda
2
890
Other Decks in Programming
See All in Programming
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
240
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
7.3k
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
120
AHC070解法紹介
eijirou
0
120
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
170
すこし踏み込む CancellationToken
htkym
0
320
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
3
350
速習iPhone Duo対応
yuukiw00w
1
540
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
120
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
1
150
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
220
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
340
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
280
Darren the Foodie - Storyboard
khoart
PRO
4
3.9k
Test your architecture with Archunit
thirion
2
2.4k
The Curse of the Amulet
leimatthew05
3
15k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
450
WENDY [Excerpt]
tessaabrams
14
39k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
380
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
57k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
Discover your Explorer Soul
emna__ayadi
2
1.3k
Transcript
RxJSのカスタムオペレータに挑戦しよう! Angular触ろうの会 in Fukuoka #5 / Mar 16, 2018 ponday
(@ponday_dev)
Profile Honda, Yusuke (@ponday_dev) Community - chibi-developer - ng-fukuoka Like
- JavaScript / TypeScript / Kotlin - RxJS / Angular / Vue.js Other skills - C# / Java / Python - Spring Boot SIer / System Engineer
loves
loves
カスタムオペレータ - 自分で独自のオペレータを定義できる - バージョン5.5でpipeが提供され、使いやすくなった - 汎用的なものは大体提供されているので、使う機会はそこま で多くない - ある程度使い慣れた人向けの機能(?)
https://github.com/ReactiveX/rxjs/blob/master/doc/operator-creation.md 公式ドキュメント
None
分かりづらい
読み解く
オペレータ?
None
入力:Observable<T> 出力:Observable<R>
None
型を付けるとこう
型を付けるとこう ココ
Observable.create - 名前の通り、Observableのインスタンスを生成する。 - 引数にSubscriber => Subscription※な関数を取る ※ 正確にはSubcriber =>
TeardownLogic TeardownLogicにSubscriptionも含まれるのでわかりやすさのため
Subscriber - next/error/completeに加えてunsubscribeも持つ - Subscriberを通して次のオペレータやsubscribeに処理を渡す ことができる。
サンプルオペレータの動作 sourceをsubscribeして値を取得
サンプルオペレータの動作 sourceの値をcallbackで処理して戻り値をnext
サンプルオペレータの動作 callbackでエラーが起これば errorに分岐
サンプルオペレータの動作 sourceのerrorやcompleteはそのまま流す
一番外側の関数はオペレータ = Observable => Observable な関数を生成するのが仕事。
どちらかと言うと中身のほうが重要
まとめ - 結構シンプルに実装できる。見慣れない要素が出てくるので 難しそうに見えるだけ。 - 乱用すべきではない(と思う) - 標準のオペレータのみで簡潔に表現できるならそのほうが良い - 読みやすさを向上できるなら利用して良い
- ちゃんとサンプルで型を付けてくれていれば ソースリーディングの入り口に良かった気はする
相変わらずRxJSは公式のドキュメントがイマイチ...
こんなところに日本語情報が https://booth.pm/ja/items/659290
※ カスタムオペレータについての記述はありません
サンプル
数値をn倍する
条件に一致しない値が流れたらerrorを起こす