SlideShare a Scribd company logo
1 of 98
Download to read offline
RxSwift
@ RxSwift
https://speakerdeck.com/bricklife/rxswiftfalseobserveontosubscribeonwoli-jie-suru
• RxMarbles
Hot
• RxSwift Operator
ReactiveX
(Driver …)
• Operator
• Hot / Cold
• RxSwift v2.5.0 (2016 7 master)
• 1
1
Operator
source
Sequence Map Filter
↑
Sequence Map Filter
↑
filter
filter
Filter
filter
source filter
Observable
map
Map
source
Map source Sequence
(Sequence Observable.of )
source
Filter source Map
source
Sequence Map Filter
source
source
Sequence Map Filter
source
source
source
Sequence Map Filter
source
source
create Operator source
• create, just, of, error, never create
Operator source
• map filter Operator
Hot subscribeOn/observeOn
source
create Operator source
• Operator
create Operator
source
• source Observable
source ( ) subscribe
• ( )subscribe
Hot / Cold Operator
source
• create Operator Observable
source
source
Sequence Map Filter
source
2
Operator
Operator
Operator
• source subscribe
• source
Operator
Sequence Map Filter Observer
subscribe
Operator
subscribe
Sequence Map Filter Observer
subscribe subscribe
source subscribe
Operator
Sequence Map Filter Observer
on on on
Operator
subscribe
Sequence Map Filter Observer
subscribe subscribe
on on on
Operator
3
• source subscribe
• subscribe
• on
: Filter
: Filter
run subscribe
: Filter
sink source subscribe
: Filter
Sequence Map Filter Observer
subscribe
subscribe
: Filter
Sequence Map Filter Observer
subscribe subscribe
source subscribe
: Filter
: Filter
on source
: Filter
Next
: Filter
: Filter
: Filter
Sequence Map Filter Observer
on
source
: Filter
Sequence Map Filter Observer
on on
✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
3
• source subscribe
• subscribe
• on
Subject …
3
• source subscribe
• subscribe
• on
create Operator …
• subscribe
3
Sink / SinkIter
( ) Operator
• source subscribe
• source
( ) Operator
• source subscribe
• source
subscribe observer
Filter
Filter
Filter
Sink
Sink
• ( )source observer
• Filter FilterSink Map MapSink
Operator Sink
(subscribe )
Sequence Map Filter Observer
Filter
Sequence Map Filter Observer
subscribe run
subscribe(observer)
Filter
Sequence Map Filter Observer
subscribe(observer)
observer
Filter
Sequence Map Filter Observer
observer FilterSink
FilterSink(observer)
Filter
Sequence Map Filter Observer
FilterSink source subscribe
source.subscribe(FilterSink(observer))
Map
Sequence Map Filter Observer
source.subscribe(FilterSink(observer))
Map
Sequence Map Filter Observer
source.subscribe(FilterSink(observer))
observer FilterSink(observer)
Map
Sequence Map Filter Observer
MapSink(FilterSink(observer))
observer FilterSink
Map
Sequence Map Filter Observer
source.subscribe(MapSink(FilterSink(observer)))
MapSink source subscribe
(on )
MapSink
Sequence Map Filter Observer
MapSink(FilterSink(observer)).on(.Next(2))
MapSink
Sequence Map Filter Observer
selector
.Next(2) → .Next(4)
MapSink
Sequence Map Filter Observer
FilterSink(observer).on(.Next(4))
FilterSink
Sequence Map Filter Observer
FilterSink(observer).on(.Next(4))
FilterSink
Sequence Map Filter Observer
value % 4 == 0
FilterSink
Sequence Map Filter Observer
observer.on(.Next(4))
✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
subscribe(MapSink(FilterSink(observer)))
Sequence Map Filter Observer
subscribe(FilterSink(observer))
subscribe(observer)
observer Sink
source subscribe
Sequence Map Filter Observer
observer.on(.Next)
FilterSink(observer).on(.Next)
MapSink(FilterSink(observer)).on(.Next)
Sink
observer
SinkIter
SinkIter
• merge flatMap ( )
Observable<Observable<E>>
SinkIter
Observable<Observable<E>>
SinkIter
Observable<Observable<E>>
Observable
subscribe Sink
SinkIter
Observable<Observable<E>>
Observable
subscribe SinkIter
Cold Observable
Cold Observable
• subscribe
• subscribe
Just
Just
subscribe ….
Just
Cold
Cold
subscribe
Just Map Filter Observer
subscribe subscribe
on on on
BehaviorSubject
BehaviorSubject
•
subscribe
BehaviorSubject
BehaviorSubject
observer
BehaviorSubject
subscribe
BehaviorSubject
subscribe observer
BehaviorSubject
BehaviorSubject
on
BehaviorSubject
BehaviorSubject
Observer
✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
• Rx Operator
•
RxSwift コードリーディングの勘所@社内RxSwift勉強会

More Related Content

What's hot

FridaによるAndroidアプリの動的解析とフッキングの基礎
FridaによるAndroidアプリの動的解析とフッキングの基礎FridaによるAndroidアプリの動的解析とフッキングの基礎
FridaによるAndroidアプリの動的解析とフッキングの基礎
ken_kitahara
 

What's hot (20)

FridaによるAndroidアプリの動的解析とフッキングの基礎
FridaによるAndroidアプリの動的解析とフッキングの基礎FridaによるAndroidアプリの動的解析とフッキングの基礎
FridaによるAndroidアプリの動的解析とフッキングの基礎
 
Payloads in Solr - Erik Hatcher, Lucidworks
Payloads in Solr - Erik Hatcher, LucidworksPayloads in Solr - Erik Hatcher, Lucidworks
Payloads in Solr - Erik Hatcher, Lucidworks
 
メディアコンテンツ向け記事検索DBとして使うElasticsearch
メディアコンテンツ向け記事検索DBとして使うElasticsearchメディアコンテンツ向け記事検索DBとして使うElasticsearch
メディアコンテンツ向け記事検索DBとして使うElasticsearch
 
Region推論アルゴリズムの実装と動向
Region推論アルゴリズムの実装と動向Region推論アルゴリズムの実装と動向
Region推論アルゴリズムの実装と動向
 
Go Friday 傑作選
Go Friday 傑作選Go Friday 傑作選
Go Friday 傑作選
 
Field collapsing/Result groupingについて
Field collapsing/Result groupingについてField collapsing/Result groupingについて
Field collapsing/Result groupingについて
 
Python製BDDツールで自動化してみた
Python製BDDツールで自動化してみたPython製BDDツールで自動化してみた
Python製BDDツールで自動化してみた
 
社内ドキュメント検索システム構築のノウハウ
社内ドキュメント検索システム構築のノウハウ社内ドキュメント検索システム構築のノウハウ
社内ドキュメント検索システム構築のノウハウ
 
たのしい高階関数
たのしい高階関数たのしい高階関数
たのしい高階関数
 
Goの時刻に関するテスト
Goの時刻に関するテストGoの時刻に関するテスト
Goの時刻に関するテスト
 
Container View Controllerを正しく使おう
Container View Controllerを正しく使おうContainer View Controllerを正しく使おう
Container View Controllerを正しく使おう
 
OpenCV 3.0 on iOS
OpenCV 3.0 on iOSOpenCV 3.0 on iOS
OpenCV 3.0 on iOS
 
代数的実数とCADの実装紹介
代数的実数とCADの実装紹介代数的実数とCADの実装紹介
代数的実数とCADの実装紹介
 
Apache Solr 入門
Apache Solr 入門Apache Solr 入門
Apache Solr 入門
 
磯野ー!関数型言語やろうぜー!
磯野ー!関数型言語やろうぜー!磯野ー!関数型言語やろうぜー!
磯野ー!関数型言語やろうぜー!
 
「スプラトゥーン」リアルタイム画像解析ツール 「IkaLog」の裏側
「スプラトゥーン」リアルタイム画像解析ツール 「IkaLog」の裏側「スプラトゥーン」リアルタイム画像解析ツール 「IkaLog」の裏側
「スプラトゥーン」リアルタイム画像解析ツール 「IkaLog」の裏側
 
30分で分かる!OSの作り方
30分で分かる!OSの作り方30分で分かる!OSの作り方
30分で分かる!OSの作り方
 
RxSwift to Combine
RxSwift to CombineRxSwift to Combine
RxSwift to Combine
 
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP
 
第1回ROS勉強会発表資料 ROS+Gazeboではじめるロボットシミュレーション
第1回ROS勉強会発表資料 ROS+Gazeboではじめるロボットシミュレーション第1回ROS勉強会発表資料 ROS+Gazeboではじめるロボットシミュレーション
第1回ROS勉強会発表資料 ROS+Gazeboではじめるロボットシミュレーション
 

Similar to RxSwift コードリーディングの勘所@社内RxSwift勉強会

Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
Erik Hatcher
 

Similar to RxSwift コードリーディングの勘所@社内RxSwift勉強会 (20)

Reactive programming in Angular 2
Reactive programming in Angular 2Reactive programming in Angular 2
Reactive programming in Angular 2
 
RxSwiftを用いたアプリ開発の実践
RxSwiftを用いたアプリ開発の実践RxSwiftを用いたアプリ開発の実践
RxSwiftを用いたアプリ開発の実践
 
[Spark meetup] Spark Streaming Overview
[Spark meetup] Spark Streaming Overview[Spark meetup] Spark Streaming Overview
[Spark meetup] Spark Streaming Overview
 
Functional Reactive Programming (FRP): Working with RxJS
Functional Reactive Programming (FRP): Working with RxJSFunctional Reactive Programming (FRP): Working with RxJS
Functional Reactive Programming (FRP): Working with RxJS
 
[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)
[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)
[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)
 
Gasimov Orkhan "Service Discovery and Coordination by Netflix Eureka and Spri...
Gasimov Orkhan "Service Discovery and Coordination by Netflix Eureka and Spri...Gasimov Orkhan "Service Discovery and Coordination by Netflix Eureka and Spri...
Gasimov Orkhan "Service Discovery and Coordination by Netflix Eureka and Spri...
 
Reactive Streams: Handling Data-Flow the Reactive Way
Reactive Streams: Handling Data-Flow the Reactive WayReactive Streams: Handling Data-Flow the Reactive Way
Reactive Streams: Handling Data-Flow the Reactive Way
 
Cdcr apachecon-talk
Cdcr apachecon-talkCdcr apachecon-talk
Cdcr apachecon-talk
 
HBaseConEast2016: How yarn timeline service v.2 unlocks 360 degree platform i...
HBaseConEast2016: How yarn timeline service v.2 unlocks 360 degree platform i...HBaseConEast2016: How yarn timeline service v.2 unlocks 360 degree platform i...
HBaseConEast2016: How yarn timeline service v.2 unlocks 360 degree platform i...
 
Feb 2013 HUG: Large Scale Data Ingest Using Apache Flume
Feb 2013 HUG: Large Scale Data Ingest Using Apache FlumeFeb 2013 HUG: Large Scale Data Ingest Using Apache Flume
Feb 2013 HUG: Large Scale Data Ingest Using Apache Flume
 
Parallel SQL and Streaming Expressions in Apache Solr 6
Parallel SQL and Streaming Expressions in Apache Solr 6Parallel SQL and Streaming Expressions in Apache Solr 6
Parallel SQL and Streaming Expressions in Apache Solr 6
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Rxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJavaRxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJava
 
BigDataSpain 2016: Stream Processing Applications with Apache Apex
BigDataSpain 2016: Stream Processing Applications with Apache ApexBigDataSpain 2016: Stream Processing Applications with Apache Apex
BigDataSpain 2016: Stream Processing Applications with Apache Apex
 
First glance at Akka 2.0
First glance at Akka 2.0First glance at Akka 2.0
First glance at Akka 2.0
 
Journey into Reactive Streams and Akka Streams
Journey into Reactive Streams and Akka StreamsJourney into Reactive Streams and Akka Streams
Journey into Reactive Streams and Akka Streams
 
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache ApexApache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
 
RxJS In-Depth - AngularConnect 2015
RxJS In-Depth - AngularConnect 2015RxJS In-Depth - AngularConnect 2015
RxJS In-Depth - AngularConnect 2015
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 

Recently uploaded

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Recently uploaded (20)

FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 

RxSwift コードリーディングの勘所@社内RxSwift勉強会