SlideShare a Scribd company logo
RxSwift: Subjects & Operators
Saravudh Sinsomros
30.03.22
What is RxSwift
Subjects
○ PublishSubjects
○ BehaviorSubjects
○ ReplaySubjects
○ AsyncSubjects
Combining Operators
○ CombineLatest
○ Merge
○ Zip
Agenda
What is RxSwift
RxSwift, simplifies
developing asynchronous
programs by allowing
your code to react to new
data and process it in
sequential, isolated
manner.
raywenderlich.com
Observer 1
Observer 2
Observer 3
Observable<Int>
2, 3, 5, 7, 11, 13, 17 |
2, 3, 5, 7, 11, 13, 17 |
2, 3, 5, 7, 11, 13, 17 |
Operator
Subjects
PublishSubjects
https://reactivex.io
Starts empty and only
emits new elements to
subscribers
Coding
subject.onNext("Green")
let subscriptionTwo = subject
.subscribe(onNext: { item in
print("subscriptionTwo: (item)")
})
subscriptionTwo.disposed(by: disposeBag)
subject.onNext("Blue")
subject.onNext("Red")
subscriptionOne: Red
subscriptionOne: Green
subscriptionOne: Blue
subscriptionTwo: Blue
PublishSubjects
let subscriptionOne = subject
.subscribe(onNext: { item in
print("subscriptionOne: (item)")
})
subscriptionOne.disposed(by: disposeBag)
let subject = PublishSubject<String>()
BehaviorSubjects
https://reactivex.io
Starts with an initial
value and replays it or
the latest element to new
subscribers
Coding
let subject = BehaviorSubject<String>(value: "Purple")
subject.onNext("Red")
subject.onNext(“Green")
subject.onNext("Blue")
let subscriptionTwo = subject
.subscribe(onNext: { item in
print("subscriptionTwo: (item)")
})
subscriptionTwo.disposed(by: disposeBag)
subscriptionOne: Purple
subscriptionOne: Red
subscriptionOne: Green
subscriptionTwo: Green
subscriptionOne: Blue
subscriptionTwo: Blue
BehaviorSubjects
let subscriptionOne = subject
.subscribe(onNext: { item in
print("subscriptionOne: (item)n")
})
subscriptionOne.disposed(by: disposeBag)
ReplaySubjects
https://reactivex.io
Initialized with a buffer
size and will maintain a
buffer of elements up to
that size and replay it to
new subscribers
Coding
let subject = ReplaySubject<String>.create(bufferSize: 3)
subject.onNext("Red")
subject.onNext("Green")
let subscriptionTwo = subject
.subscribe(onNext: { item in
print("subscriptionTwo: (item)n")
})
subscriptionTwo.disposed(by: disposeBag)
subject.onNext("Blue")
subscriptionOne: Red
subscriptionOne: Green
subscriptionTwo: Red
subscriptionTwo: Green
subscriptionOne: Blue
subscriptionTwo: Blue
ReplaySubjects
let subscriptionOne = subject
.subscribe(onNext: { item in
print("subscriptionOne: (item)n")
})
subscriptionOne.disposed(by: disposeBag)
AsyncSubjects
https://reactivex.io
Emits only the last value
Coding
let subject = AsyncSubject<String>()
subject.onNext("Red")
let subscriptionTwo = subject
.subscribe(onNext: { item in
print("subscriptionTwo: (item)n")
})
subscriptionTwo.disposed(by: disposeBag)
subject.onNext("Green")
subject.onNext("Blue")
subject.onCompleted()
subscriptionOne: Blue
subscriptionTwo: Blue
AsyncSubjects
let subscriptionOne = subject
.subscribe(onNext: { item in
print("subscriptionOne: (item)n")
})
subscriptionOne.disposed(by: disposeBag)
Combining Operators
Merge
combine multiple
Observables into one by
merging their emissions
https://reactivex.io
Coding
let input1 = PublishSubject<String>()
let input2 = PublishSubject<String>()
let output = Observable.of(input1.asObservable(),
input2.asObservable()).merge()
output.subscribe(onNext: { item in
print("(item)n")
}).disposed(by: disposeBag)
input1.onNext("20")
input1.onNext("40")
input1.onNext("60")
input2.onNext("1")
input1.onNext("80")
input1.onNext("100")
input2.onNext("1")
20
40
60
1
80
100
1
Merge
CombineLatest
combine values from
several sequences
together
https://reactivex.io
Coding
let input1 = PublishSubject<String>()
let input2 = PublishSubject<String>()
let output = Observable.combineLatest(input1, input2, resultSelector: {
lastTop, lastBottom in
"((lastTop)(lastBottom))"
})
output.subscribe(onNext: { item in
print("combineLatest: (item)n")
}).disposed(by: disposeBag)
input1.onNext("1")
input2.onNext("A")
input1.onNext("2")
input2.onNext("B")
input2.onNext("C")
input2.onNext("D")
input1.onNext("3")
input1.onNext("4")
(1A)
(2A)
(2B)
(2C)
(2D)
(3D)
(4D)
CombineLatest
Zip
combine the emissions
of multiple Observables
together via a specified
function and emit single
items for each
combination based on
the results of this
function
https://reactivex.io
Coding
let input1 = PublishSubject<String>()
let input2 = PublishSubject<String>()
let output = Observable.zip(input1.asObservable(), input2.asObservable())
output.subscribe(onNext: { item1, item2 in
print("(item1)(item2)n")
}).disposed(by: disposeBag)
input1.onNext("1")
input2.onNext("A")
input1.onNext("2")
input2.onNext("B")
input2.onNext("C")
input2.onNext("D")
input1.onNext("3")
input1.onNext("4")
input1.onCompleted()
input2.onNext("E")
1A
2B
3C
4D
Zip
Discussion
“First, solve the problem.
Then, write the code.”
- John Johnson
UPCOMING MEETUP
Check out our event page
Stay tuned for whatʼs coming next!

More Related Content

What's hot

最新のデータベース技術の方向性で思うこと
最新のデータベース技術の方向性で思うこと最新のデータベース技術の方向性で思うこと
最新のデータベース技術の方向性で思うこと
Masayoshi Hagiwara
 
Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4
Synapseindiappsdevelopment
 
Fetch data from form
Fetch data from formFetch data from form
Fetch data from form
Shahriar Malik
 
Getting your data in and out of elasticsearch: let me count the ways
Getting your data in and out of elasticsearch: let me count the waysGetting your data in and out of elasticsearch: let me count the ways
Getting your data in and out of elasticsearch: let me count the ways
🥑 Jay Miller
 
Climate data in r with the raster package
Climate data in r with the raster packageClimate data in r with the raster package
Climate data in r with the raster packageAlberto Labarga
 
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
baabtra.com - No. 1 supplier of quality freshers
 
MongoDB.local DC 2018: Scaling Realtime Apps with Change Streams
MongoDB.local DC 2018: Scaling Realtime Apps with Change StreamsMongoDB.local DC 2018: Scaling Realtime Apps with Change Streams
MongoDB.local DC 2018: Scaling Realtime Apps with Change Streams
MongoDB
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
InfluxData
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
Bruce McPherson
 
Data management with ado
Data management with adoData management with ado
Data management with adoDinesh kumar
 
New text document
New text documentNew text document
New text document
Tam Ngo
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed versionBruce McPherson
 
Reactive Extensions (Rx)
Reactive Extensions (Rx)Reactive Extensions (Rx)
Reactive Extensions (Rx)
Mark Allan
 
Streaming data to s3 using akka streams
Streaming data to s3 using akka streamsStreaming data to s3 using akka streams
Streaming data to s3 using akka streams
Mikhail Girkin
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodbLee Theobald
 
My Gentle Introduction to RxJS
My Gentle Introduction to RxJSMy Gentle Introduction to RxJS
My Gentle Introduction to RxJS
Mattia Occhiuto
 
Ns2 ns3 training in mohali
Ns2 ns3 training in mohaliNs2 ns3 training in mohali
Ns2 ns3 training in mohali
Arwinder paul singh
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascript
Changhwan Yi
 

What's hot (20)

最新のデータベース技術の方向性で思うこと
最新のデータベース技術の方向性で思うこと最新のデータベース技術の方向性で思うこと
最新のデータベース技術の方向性で思うこと
 
Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4
 
Fetch data from form
Fetch data from formFetch data from form
Fetch data from form
 
Getting your data in and out of elasticsearch: let me count the ways
Getting your data in and out of elasticsearch: let me count the waysGetting your data in and out of elasticsearch: let me count the ways
Getting your data in and out of elasticsearch: let me count the ways
 
Climate data in r with the raster package
Climate data in r with the raster packageClimate data in r with the raster package
Climate data in r with the raster package
 
Sse
SseSse
Sse
 
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
 
MongoDB.local DC 2018: Scaling Realtime Apps with Change Streams
MongoDB.local DC 2018: Scaling Realtime Apps with Change StreamsMongoDB.local DC 2018: Scaling Realtime Apps with Change Streams
MongoDB.local DC 2018: Scaling Realtime Apps with Change Streams
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
 
Data management with ado
Data management with adoData management with ado
Data management with ado
 
New text document
New text documentNew text document
New text document
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
 
Reactive Extensions (Rx)
Reactive Extensions (Rx)Reactive Extensions (Rx)
Reactive Extensions (Rx)
 
Streaming data to s3 using akka streams
Streaming data to s3 using akka streamsStreaming data to s3 using akka streams
Streaming data to s3 using akka streams
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
 
My Gentle Introduction to RxJS
My Gentle Introduction to RxJSMy Gentle Introduction to RxJS
My Gentle Introduction to RxJS
 
Ns2 ns3 training in mohali
Ns2 ns3 training in mohaliNs2 ns3 training in mohali
Ns2 ns3 training in mohali
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascript
 
Toy Model Overview
Toy Model OverviewToy Model Overview
Toy Model Overview
 

Similar to RxSubject And Operators

Rx for Android & iOS by Harin Trivedi
Rx for Android & iOS  by Harin TrivediRx for Android & iOS  by Harin Trivedi
Rx for Android & iOS by Harin Trivedi
harintrivedi
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
Brainhub
 
Understanding reactive programming with microsoft reactive extensions
Understanding reactive programming  with microsoft reactive extensionsUnderstanding reactive programming  with microsoft reactive extensions
Understanding reactive programming with microsoft reactive extensions
Oleksandr Zhevzhyk
 
Reactive Programming no Android
Reactive Programming no AndroidReactive Programming no Android
Reactive Programming no Android
Guilherme Branco
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
Rick Warren
 
ReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better TogetherReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better Together
Colin Eberhardt
 
Demystifying Reactive Programming
Demystifying Reactive ProgrammingDemystifying Reactive Programming
Demystifying Reactive Programming
Tom Bulatewicz, PhD
 
Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2
JollyRogers5
 
RxJava for Android - GDG DevFest Ukraine 2015
RxJava for Android - GDG DevFest Ukraine 2015RxJava for Android - GDG DevFest Ukraine 2015
RxJava for Android - GDG DevFest Ukraine 2015
Constantine Mars
 
GKAC 2015 Apr. - RxAndroid
GKAC 2015 Apr. - RxAndroidGKAC 2015 Apr. - RxAndroid
GKAC 2015 Apr. - RxAndroid
GDG Korea
 
The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.9 book - Part 90 of 210The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.9 book - Part 90 of 210
Mahmoud Samir Fayed
 
Writing Domain-Specific Languages for BeepBeep
Writing Domain-Specific Languages for BeepBeepWriting Domain-Specific Languages for BeepBeep
Writing Domain-Specific Languages for BeepBeep
Sylvain Hallé
 
RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 Slides
YarikS
 
Saving lives with rx java
Saving lives with rx javaSaving lives with rx java
Saving lives with rx java
Shahar Barsheshet
 
Reactive programming with RxAndroid
Reactive programming with RxAndroidReactive programming with RxAndroid
Reactive programming with RxAndroid
Savvycom Savvycom
 
Rxandroid
RxandroidRxandroid
Rxandroid
Thinh Thanh
 
RxAndroid
RxAndroidRxAndroid
RxAndroid
Thinh Thanh
 
The Ring programming language version 1.6 book - Part 81 of 189
The Ring programming language version 1.6 book - Part 81 of 189The Ring programming language version 1.6 book - Part 81 of 189
The Ring programming language version 1.6 book - Part 81 of 189
Mahmoud Samir Fayed
 
Reactive Programming with RxSwift
Reactive Programming with RxSwiftReactive Programming with RxSwift
Reactive Programming with RxSwift
Scott Gardner
 
An Introduction to Reactive Cocoa
An Introduction to Reactive CocoaAn Introduction to Reactive Cocoa
An Introduction to Reactive Cocoa
SmartLogic
 

Similar to RxSubject And Operators (20)

Rx for Android & iOS by Harin Trivedi
Rx for Android & iOS  by Harin TrivediRx for Android & iOS  by Harin Trivedi
Rx for Android & iOS by Harin Trivedi
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
 
Understanding reactive programming with microsoft reactive extensions
Understanding reactive programming  with microsoft reactive extensionsUnderstanding reactive programming  with microsoft reactive extensions
Understanding reactive programming with microsoft reactive extensions
 
Reactive Programming no Android
Reactive Programming no AndroidReactive Programming no Android
Reactive Programming no Android
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
ReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better TogetherReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better Together
 
Demystifying Reactive Programming
Demystifying Reactive ProgrammingDemystifying Reactive Programming
Demystifying Reactive Programming
 
Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2
 
RxJava for Android - GDG DevFest Ukraine 2015
RxJava for Android - GDG DevFest Ukraine 2015RxJava for Android - GDG DevFest Ukraine 2015
RxJava for Android - GDG DevFest Ukraine 2015
 
GKAC 2015 Apr. - RxAndroid
GKAC 2015 Apr. - RxAndroidGKAC 2015 Apr. - RxAndroid
GKAC 2015 Apr. - RxAndroid
 
The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.9 book - Part 90 of 210The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.9 book - Part 90 of 210
 
Writing Domain-Specific Languages for BeepBeep
Writing Domain-Specific Languages for BeepBeepWriting Domain-Specific Languages for BeepBeep
Writing Domain-Specific Languages for BeepBeep
 
RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 Slides
 
Saving lives with rx java
Saving lives with rx javaSaving lives with rx java
Saving lives with rx java
 
Reactive programming with RxAndroid
Reactive programming with RxAndroidReactive programming with RxAndroid
Reactive programming with RxAndroid
 
Rxandroid
RxandroidRxandroid
Rxandroid
 
RxAndroid
RxAndroidRxAndroid
RxAndroid
 
The Ring programming language version 1.6 book - Part 81 of 189
The Ring programming language version 1.6 book - Part 81 of 189The Ring programming language version 1.6 book - Part 81 of 189
The Ring programming language version 1.6 book - Part 81 of 189
 
Reactive Programming with RxSwift
Reactive Programming with RxSwiftReactive Programming with RxSwift
Reactive Programming with RxSwift
 
An Introduction to Reactive Cocoa
An Introduction to Reactive CocoaAn Introduction to Reactive Cocoa
An Introduction to Reactive Cocoa
 

More from Seven Peaks Speaks

BKK Web: Working with SEO
BKK Web: Working with SEOBKK Web: Working with SEO
BKK Web: Working with SEO
Seven Peaks Speaks
 
Seven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made EasySeven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks
 
Seven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose AnimationSeven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks
 
Seven Peaks Speaks - Compose Navigation
Seven Peaks Speaks - Compose NavigationSeven Peaks Speaks - Compose Navigation
Seven Peaks Speaks - Compose Navigation
Seven Peaks Speaks
 
How to Get Better Performance Out of Your App
How to Get Better Performance Out of Your AppHow to Get Better Performance Out of Your App
How to Get Better Performance Out of Your App
Seven Peaks Speaks
 
Concurrency in Swift
Concurrency in SwiftConcurrency in Swift
Concurrency in Swift
Seven Peaks Speaks
 
DevSecOps on Azure
DevSecOps on AzureDevSecOps on Azure
DevSecOps on Azure
Seven Peaks Speaks
 
Secure Development of Azure Function
Secure Development of Azure FunctionSecure Development of Azure Function
Secure Development of Azure Function
Seven Peaks Speaks
 
Develop Security & Compliances in Azure
Develop Security & Compliances in AzureDevelop Security & Compliances in Azure
Develop Security & Compliances in Azure
Seven Peaks Speaks
 
Effective Lists Management
Effective Lists ManagementEffective Lists Management
Effective Lists Management
Seven Peaks Speaks
 
Layout Preview Tooling
Layout Preview ToolingLayout Preview Tooling
Layout Preview Tooling
Seven Peaks Speaks
 
Background Processing With Work Manager
Background Processing With Work ManagerBackground Processing With Work Manager
Background Processing With Work Manager
Seven Peaks Speaks
 
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Seven Peaks Speaks
 
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Seven Peaks Speaks
 
Delivering react app with confidence: Testing Pyramid
Delivering react app with confidence: Testing PyramidDelivering react app with confidence: Testing Pyramid
Delivering react app with confidence: Testing Pyramid
Seven Peaks Speaks
 
React context
React context  React context
React context
Seven Peaks Speaks
 
Getting hooked on performance and clean code
Getting hooked on performance and clean codeGetting hooked on performance and clean code
Getting hooked on performance and clean code
Seven Peaks Speaks
 
Establishing secure Biometric authentication in Android
Establishing secure Biometric authentication in AndroidEstablishing secure Biometric authentication in Android
Establishing secure Biometric authentication in Android
Seven Peaks Speaks
 
Utilizing kotlin flows in an android application
Utilizing kotlin flows in an android applicationUtilizing kotlin flows in an android application
Utilizing kotlin flows in an android application
Seven Peaks Speaks
 
Continuously deploy a containerized app to “Azure App Service”
Continuously deploy a containerized app to “Azure App Service”Continuously deploy a containerized app to “Azure App Service”
Continuously deploy a containerized app to “Azure App Service”
Seven Peaks Speaks
 

More from Seven Peaks Speaks (20)

BKK Web: Working with SEO
BKK Web: Working with SEOBKK Web: Working with SEO
BKK Web: Working with SEO
 
Seven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made EasySeven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made Easy
 
Seven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose AnimationSeven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose Animation
 
Seven Peaks Speaks - Compose Navigation
Seven Peaks Speaks - Compose NavigationSeven Peaks Speaks - Compose Navigation
Seven Peaks Speaks - Compose Navigation
 
How to Get Better Performance Out of Your App
How to Get Better Performance Out of Your AppHow to Get Better Performance Out of Your App
How to Get Better Performance Out of Your App
 
Concurrency in Swift
Concurrency in SwiftConcurrency in Swift
Concurrency in Swift
 
DevSecOps on Azure
DevSecOps on AzureDevSecOps on Azure
DevSecOps on Azure
 
Secure Development of Azure Function
Secure Development of Azure FunctionSecure Development of Azure Function
Secure Development of Azure Function
 
Develop Security & Compliances in Azure
Develop Security & Compliances in AzureDevelop Security & Compliances in Azure
Develop Security & Compliances in Azure
 
Effective Lists Management
Effective Lists ManagementEffective Lists Management
Effective Lists Management
 
Layout Preview Tooling
Layout Preview ToolingLayout Preview Tooling
Layout Preview Tooling
 
Background Processing With Work Manager
Background Processing With Work ManagerBackground Processing With Work Manager
Background Processing With Work Manager
 
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
 
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
 
Delivering react app with confidence: Testing Pyramid
Delivering react app with confidence: Testing PyramidDelivering react app with confidence: Testing Pyramid
Delivering react app with confidence: Testing Pyramid
 
React context
React context  React context
React context
 
Getting hooked on performance and clean code
Getting hooked on performance and clean codeGetting hooked on performance and clean code
Getting hooked on performance and clean code
 
Establishing secure Biometric authentication in Android
Establishing secure Biometric authentication in AndroidEstablishing secure Biometric authentication in Android
Establishing secure Biometric authentication in Android
 
Utilizing kotlin flows in an android application
Utilizing kotlin flows in an android applicationUtilizing kotlin flows in an android application
Utilizing kotlin flows in an android application
 
Continuously deploy a containerized app to “Azure App Service”
Continuously deploy a containerized app to “Azure App Service”Continuously deploy a containerized app to “Azure App Service”
Continuously deploy a containerized app to “Azure App Service”
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 

RxSubject And Operators

  • 1. RxSwift: Subjects & Operators Saravudh Sinsomros 30.03.22
  • 2. What is RxSwift Subjects ○ PublishSubjects ○ BehaviorSubjects ○ ReplaySubjects ○ AsyncSubjects Combining Operators ○ CombineLatest ○ Merge ○ Zip Agenda
  • 3. What is RxSwift RxSwift, simplifies developing asynchronous programs by allowing your code to react to new data and process it in sequential, isolated manner. raywenderlich.com Observer 1 Observer 2 Observer 3 Observable<Int> 2, 3, 5, 7, 11, 13, 17 | 2, 3, 5, 7, 11, 13, 17 | 2, 3, 5, 7, 11, 13, 17 | Operator
  • 5. PublishSubjects https://reactivex.io Starts empty and only emits new elements to subscribers
  • 6. Coding subject.onNext("Green") let subscriptionTwo = subject .subscribe(onNext: { item in print("subscriptionTwo: (item)") }) subscriptionTwo.disposed(by: disposeBag) subject.onNext("Blue") subject.onNext("Red") subscriptionOne: Red subscriptionOne: Green subscriptionOne: Blue subscriptionTwo: Blue PublishSubjects let subscriptionOne = subject .subscribe(onNext: { item in print("subscriptionOne: (item)") }) subscriptionOne.disposed(by: disposeBag) let subject = PublishSubject<String>()
  • 7. BehaviorSubjects https://reactivex.io Starts with an initial value and replays it or the latest element to new subscribers
  • 8. Coding let subject = BehaviorSubject<String>(value: "Purple") subject.onNext("Red") subject.onNext(“Green") subject.onNext("Blue") let subscriptionTwo = subject .subscribe(onNext: { item in print("subscriptionTwo: (item)") }) subscriptionTwo.disposed(by: disposeBag) subscriptionOne: Purple subscriptionOne: Red subscriptionOne: Green subscriptionTwo: Green subscriptionOne: Blue subscriptionTwo: Blue BehaviorSubjects let subscriptionOne = subject .subscribe(onNext: { item in print("subscriptionOne: (item)n") }) subscriptionOne.disposed(by: disposeBag)
  • 9. ReplaySubjects https://reactivex.io Initialized with a buffer size and will maintain a buffer of elements up to that size and replay it to new subscribers
  • 10. Coding let subject = ReplaySubject<String>.create(bufferSize: 3) subject.onNext("Red") subject.onNext("Green") let subscriptionTwo = subject .subscribe(onNext: { item in print("subscriptionTwo: (item)n") }) subscriptionTwo.disposed(by: disposeBag) subject.onNext("Blue") subscriptionOne: Red subscriptionOne: Green subscriptionTwo: Red subscriptionTwo: Green subscriptionOne: Blue subscriptionTwo: Blue ReplaySubjects let subscriptionOne = subject .subscribe(onNext: { item in print("subscriptionOne: (item)n") }) subscriptionOne.disposed(by: disposeBag)
  • 12. Coding let subject = AsyncSubject<String>() subject.onNext("Red") let subscriptionTwo = subject .subscribe(onNext: { item in print("subscriptionTwo: (item)n") }) subscriptionTwo.disposed(by: disposeBag) subject.onNext("Green") subject.onNext("Blue") subject.onCompleted() subscriptionOne: Blue subscriptionTwo: Blue AsyncSubjects let subscriptionOne = subject .subscribe(onNext: { item in print("subscriptionOne: (item)n") }) subscriptionOne.disposed(by: disposeBag)
  • 14. Merge combine multiple Observables into one by merging their emissions https://reactivex.io
  • 15. Coding let input1 = PublishSubject<String>() let input2 = PublishSubject<String>() let output = Observable.of(input1.asObservable(), input2.asObservable()).merge() output.subscribe(onNext: { item in print("(item)n") }).disposed(by: disposeBag) input1.onNext("20") input1.onNext("40") input1.onNext("60") input2.onNext("1") input1.onNext("80") input1.onNext("100") input2.onNext("1") 20 40 60 1 80 100 1 Merge
  • 16. CombineLatest combine values from several sequences together https://reactivex.io
  • 17. Coding let input1 = PublishSubject<String>() let input2 = PublishSubject<String>() let output = Observable.combineLatest(input1, input2, resultSelector: { lastTop, lastBottom in "((lastTop)(lastBottom))" }) output.subscribe(onNext: { item in print("combineLatest: (item)n") }).disposed(by: disposeBag) input1.onNext("1") input2.onNext("A") input1.onNext("2") input2.onNext("B") input2.onNext("C") input2.onNext("D") input1.onNext("3") input1.onNext("4") (1A) (2A) (2B) (2C) (2D) (3D) (4D) CombineLatest
  • 18. Zip combine the emissions of multiple Observables together via a specified function and emit single items for each combination based on the results of this function https://reactivex.io
  • 19. Coding let input1 = PublishSubject<String>() let input2 = PublishSubject<String>() let output = Observable.zip(input1.asObservable(), input2.asObservable()) output.subscribe(onNext: { item1, item2 in print("(item1)(item2)n") }).disposed(by: disposeBag) input1.onNext("1") input2.onNext("A") input1.onNext("2") input2.onNext("B") input2.onNext("C") input2.onNext("D") input1.onNext("3") input1.onNext("4") input1.onCompleted() input2.onNext("E") 1A 2B 3C 4D Zip
  • 21. “First, solve the problem. Then, write the code.” - John Johnson
  • 22. UPCOMING MEETUP Check out our event page Stay tuned for whatʼs coming next!