SlideShare a Scribd company logo
1 of 27
Download to read offline
RxSwift
The Power in your fingers
Favara Vincenzo
UI interactions between event
and validations
UI
Witch db use depending of your
operations
Data Storage
Thinking as modular
architecture to manage the
app complexity
Architecture
Sometimes network calls
need to be triggered in
cascade
Networking
Starting new Mobile App project
What’s the most relevant troubles starting a new mobile app?
Architecture complexity
Apple SDK offers a huge variety of APIs
Using Delegates requires you
to adopt different patterns for
notifications, closures,
callbacks...
Rx heros family are here for you.
They offer an alternative approach that is both clear and concise, to manage
asynchronous tasks and events.
Acting to the configuration way instead to classic way
ReactiveX Heros
ReactiveX is a library for composing asynchronous events by using observable sequences.
RxJava
RxJs
RxSwift
RxPHP
Rx.NET
RxKotlin
Hello!
Let me introduce myself
rxswift.slack.com @rxswift
I am Ironman
“I am a reactive programming library for iOS.
I make it easy to program dynamic apps that
respond to data changes and user events by
using observables.”
github.com/ReactiveX/RxSwift
Simplified Multi-thread
Switching Main/Backgrounds threads in one line
Multi platform
Rx exists for the most used languages
Huge communities
Communities are actives in socials too
Everything is observable
Observable is a asynchronous sequence
Composable & Reusable
composed by structures and operators
Async is Declarative
definitions are immutable, data changes
Rx SuperPowers
Infinity gountlet in your hand!
What’s an Observable?
It’s a async sequence or stream of emitted items
Subscription Events:
- onNext
- onError
- onComplete
Composable & Reusable
RxSwift provides Structures and Operators
● The structures provide different ways
of publishing information.
● The operations transform, decorate,
compose, etc, the information.
You can check here:
http://reactivex.io/documentation/operators.html
PublishSubject
Start empty
Emit new next event to new
subscribers
ReplaySubject
Start empty with a buffer size
Replays buffer to new subscribers
BehaviorSubject
Start with initial value
Replays initial / latest value to new
subscribers
Structures
Different ways of publishing information
Create Transform Filter Combine Error Utility
Operators
Some of category operators
● create
● just
● from
● flatMap
● map
● groupBy
● filter
● distinct
● ignoreElements
● combineLatest
● merge
● zip
● catch
● retry
● subscribe
● observeOn
● delay
http://reactivex.io/documentation/operators.html
Async is Declarative
Definitions are immutable, data changes
Declarative code enables you to
describe a complex async
workflow at a high level in a few
lines passing from traditional
nested callbacks, delegates,
notifications, kvo, etc to a
configured data steps
Tap stream
Items stream
Response stream
Request stream
Simplified Multi-threading
Switching on different threads is easier
There are situations in which you need to
perform tasks in different threads.
You can easy listen to an event on the
main thread and react in background and
switch back to the main thread to show
the results.
Tap stream
Items stream
Response stream
Request stream
observeOn( .background)
observeOn( .main)
Reactive programming is a way of working, it’s a design pattern, or a set of them for all that matters. The same standardisation
comes in different languages and platforms. So If you learn Reactive Programming in Swift, you can take it with you to another
platform and language.
Multi-platform
Rx is different languages with a huge community.
RxJava
RxSwift
RxJs
Rx.NET
UniRx
RxScala
RxCpp
RxLua
Rx.rb
RxPY
RxGo
RxGroovy
RxKotlin
RxDart
RxPHP
http://reactivex.io/languages.html
RxSwift world is huge so you can have some troubles
during your way.
Here there are the most dangerous problems you can find
Wrong superpower use
With great power comes great responsibility
Learning curve
The learning
process is
intimidating at
the beginning.
Memory leak
Be careful with
self references
inside closures
Debugging
Stack traces are a
lot bigger,
It’s hard to find
crash/bug
reasons
Abusing
Don’t use for
everything if you
don’t need it
Avoid Memory leak
Avoid the strong reference cycle inside closures
If the closure is owned by scope and not
by the class (example: in-line closures) you
do not have to use [weak self] because
it will be released when the scope is left.
If the closure is passed in it may or may
not be owned by the class (a property for
example) and it is prudent to use [weak
self] incase it is owned by the class.
Debugging in RxSwift
Is it possible debug easy?
First: What is a Fast-Fish? Alive
or dead a fish is technically fast,
when it is connected with an
occupied ship or boat.
Let’s code...
Try to write an example
{ }
Use Cases
Using RxSwift in a common use cases:
- Perform and display a research
- Connect a single api call to two distinct collections
- Set up a chat gui
Call BE after
300ms each time
type a new letter
and in the case
cancel previous
call
For each result
found create a cell
in the table view if
exist value
When you create an ios app with a search toolbar, you are going to solve some common problems like calling BE after
waiting time and display results in a table view
Search and results
Try to figure out the problem in the use case
RxSwift
Operators:
- debounce
- distinct
- observeOn
- flatMap
- bind
- dispose
When you create an ios app with more than one only
collection view, you could have necessity to split your
retrieved data to both collection view
- Steps:
● Retrieve Data Movie with all own actors inside
● Save Movie on top collection view and all actors
in main collection view
Two collections
Try to figure out the problem in the use case
RxSwift
Operators:
- observeOn
- flatMap
- share
- bind
- dispose
Listen for new
received
messages
For each one put a
dots cell before it
appears disabling
user input sending
When you create an ios app with a chat system inside, you are going to solve some common problems like the messages
retrieving and receiving
Messages in a chat
Try to figure out the problem in the use case
RxSwift
Operators:
- observeOn
- map
- concatMap
- delay
- flatMap
- dispose
RxSwift
Libs:
- Alamofire
- RxAlamofire
https://github.com/RxSwiftCommunity/RxAlamofire
95%
WRITE A TITLE HERE
First: What is a Fast-Fish? Alive
or dead a fish is technically fast,
when it is connected with an
occupied ship or boat, by any
medium at all controllable by
the occupant oR
Pratics
Reactive thinking way
Studying RxSwift components and operators
You want to refactor yesterday’s code
Personal Experience
What I learned and what’s my feeling about RxSwift
Thank You!
Favara Vincenzo

More Related Content

Similar to Rx Swift

React gsg presentation with ryan jung & elias malik
React   gsg presentation with ryan jung & elias malikReact   gsg presentation with ryan jung & elias malik
React gsg presentation with ryan jung & elias malikLama K Banna
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx javaCongTrung Vnit
 
RxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android MontréalRxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android MontréalSidereo
 
Spring Boot & Spring Cloud on PAS- Nate Schutta (2/2)
Spring Boot & Spring Cloud on PAS- Nate Schutta (2/2)Spring Boot & Spring Cloud on PAS- Nate Schutta (2/2)
Spring Boot & Spring Cloud on PAS- Nate Schutta (2/2)VMware Tanzu
 
Do's and don'ts when deploying akka in production
Do's and don'ts when deploying akka in productionDo's and don'ts when deploying akka in production
Do's and don'ts when deploying akka in productionjglobal
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN ControllerSumit Arora
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaNexThoughts Technologies
 
Get Started with JavaScript Frameworks
Get Started with JavaScript FrameworksGet Started with JavaScript Frameworks
Get Started with JavaScript FrameworksChristian Gaetano
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsKonrad Malawski
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011YoungSu Son
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipseanshunjain
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016Trayan Iliev
 
Stream Processing with CompletableFuture and Flow in Java 9
Stream Processing with CompletableFuture and Flow in Java 9Stream Processing with CompletableFuture and Flow in Java 9
Stream Processing with CompletableFuture and Flow in Java 9Trayan Iliev
 

Similar to Rx Swift (20)

React gsg presentation with ryan jung & elias malik
React   gsg presentation with ryan jung & elias malikReact   gsg presentation with ryan jung & elias malik
React gsg presentation with ryan jung & elias malik
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
 
RxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android MontréalRxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android Montréal
 
Combine in iOS - Basics
Combine in iOS - BasicsCombine in iOS - Basics
Combine in iOS - Basics
 
Akka (1)
Akka (1)Akka (1)
Akka (1)
 
DZone_RC_RxJS
DZone_RC_RxJSDZone_RC_RxJS
DZone_RC_RxJS
 
Spring Boot & Spring Cloud on PAS- Nate Schutta (2/2)
Spring Boot & Spring Cloud on PAS- Nate Schutta (2/2)Spring Boot & Spring Cloud on PAS- Nate Schutta (2/2)
Spring Boot & Spring Cloud on PAS- Nate Schutta (2/2)
 
Do's and don'ts when deploying akka in production
Do's and don'ts when deploying akka in productionDo's and don'ts when deploying akka in production
Do's and don'ts when deploying akka in production
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN Controller
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
Get Started with JavaScript Frameworks
Get Started with JavaScript FrameworksGet Started with JavaScript Frameworks
Get Started with JavaScript Frameworks
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabs
 
Asynchronyin net
Asynchronyin netAsynchronyin net
Asynchronyin net
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
Reactive programming intro
Reactive programming introReactive programming intro
Reactive programming intro
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016
 
Stream Processing with CompletableFuture and Flow in Java 9
Stream Processing with CompletableFuture and Flow in Java 9Stream Processing with CompletableFuture and Flow in Java 9
Stream Processing with CompletableFuture and Flow in Java 9
 

Recently uploaded

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 

Recently uploaded (20)

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 

Rx Swift

  • 1. RxSwift The Power in your fingers Favara Vincenzo
  • 2. UI interactions between event and validations UI Witch db use depending of your operations Data Storage Thinking as modular architecture to manage the app complexity Architecture Sometimes network calls need to be triggered in cascade Networking Starting new Mobile App project What’s the most relevant troubles starting a new mobile app?
  • 3. Architecture complexity Apple SDK offers a huge variety of APIs Using Delegates requires you to adopt different patterns for notifications, closures, callbacks...
  • 4. Rx heros family are here for you. They offer an alternative approach that is both clear and concise, to manage asynchronous tasks and events. Acting to the configuration way instead to classic way ReactiveX Heros ReactiveX is a library for composing asynchronous events by using observable sequences. RxJava RxJs RxSwift RxPHP Rx.NET RxKotlin
  • 5. Hello! Let me introduce myself rxswift.slack.com @rxswift I am Ironman “I am a reactive programming library for iOS. I make it easy to program dynamic apps that respond to data changes and user events by using observables.” github.com/ReactiveX/RxSwift
  • 6. Simplified Multi-thread Switching Main/Backgrounds threads in one line Multi platform Rx exists for the most used languages Huge communities Communities are actives in socials too Everything is observable Observable is a asynchronous sequence Composable & Reusable composed by structures and operators Async is Declarative definitions are immutable, data changes Rx SuperPowers Infinity gountlet in your hand!
  • 7. What’s an Observable? It’s a async sequence or stream of emitted items Subscription Events: - onNext - onError - onComplete
  • 8. Composable & Reusable RxSwift provides Structures and Operators ● The structures provide different ways of publishing information. ● The operations transform, decorate, compose, etc, the information. You can check here: http://reactivex.io/documentation/operators.html
  • 9. PublishSubject Start empty Emit new next event to new subscribers ReplaySubject Start empty with a buffer size Replays buffer to new subscribers BehaviorSubject Start with initial value Replays initial / latest value to new subscribers Structures Different ways of publishing information
  • 10. Create Transform Filter Combine Error Utility Operators Some of category operators ● create ● just ● from ● flatMap ● map ● groupBy ● filter ● distinct ● ignoreElements ● combineLatest ● merge ● zip ● catch ● retry ● subscribe ● observeOn ● delay http://reactivex.io/documentation/operators.html
  • 11. Async is Declarative Definitions are immutable, data changes Declarative code enables you to describe a complex async workflow at a high level in a few lines passing from traditional nested callbacks, delegates, notifications, kvo, etc to a configured data steps Tap stream Items stream Response stream Request stream
  • 12. Simplified Multi-threading Switching on different threads is easier There are situations in which you need to perform tasks in different threads. You can easy listen to an event on the main thread and react in background and switch back to the main thread to show the results. Tap stream Items stream Response stream Request stream observeOn( .background) observeOn( .main)
  • 13. Reactive programming is a way of working, it’s a design pattern, or a set of them for all that matters. The same standardisation comes in different languages and platforms. So If you learn Reactive Programming in Swift, you can take it with you to another platform and language. Multi-platform Rx is different languages with a huge community. RxJava RxSwift RxJs Rx.NET UniRx RxScala RxCpp RxLua Rx.rb RxPY RxGo RxGroovy RxKotlin RxDart RxPHP http://reactivex.io/languages.html
  • 14. RxSwift world is huge so you can have some troubles during your way. Here there are the most dangerous problems you can find Wrong superpower use With great power comes great responsibility Learning curve The learning process is intimidating at the beginning. Memory leak Be careful with self references inside closures Debugging Stack traces are a lot bigger, It’s hard to find crash/bug reasons Abusing Don’t use for everything if you don’t need it
  • 15. Avoid Memory leak Avoid the strong reference cycle inside closures If the closure is owned by scope and not by the class (example: in-line closures) you do not have to use [weak self] because it will be released when the scope is left. If the closure is passed in it may or may not be owned by the class (a property for example) and it is prudent to use [weak self] incase it is owned by the class.
  • 16. Debugging in RxSwift Is it possible debug easy? First: What is a Fast-Fish? Alive or dead a fish is technically fast, when it is connected with an occupied ship or boat.
  • 17. Let’s code... Try to write an example { }
  • 18. Use Cases Using RxSwift in a common use cases: - Perform and display a research - Connect a single api call to two distinct collections - Set up a chat gui
  • 19. Call BE after 300ms each time type a new letter and in the case cancel previous call For each result found create a cell in the table view if exist value When you create an ios app with a search toolbar, you are going to solve some common problems like calling BE after waiting time and display results in a table view Search and results Try to figure out the problem in the use case
  • 20. RxSwift Operators: - debounce - distinct - observeOn - flatMap - bind - dispose
  • 21. When you create an ios app with more than one only collection view, you could have necessity to split your retrieved data to both collection view - Steps: ● Retrieve Data Movie with all own actors inside ● Save Movie on top collection view and all actors in main collection view Two collections Try to figure out the problem in the use case
  • 23. Listen for new received messages For each one put a dots cell before it appears disabling user input sending When you create an ios app with a chat system inside, you are going to solve some common problems like the messages retrieving and receiving Messages in a chat Try to figure out the problem in the use case
  • 24. RxSwift Operators: - observeOn - map - concatMap - delay - flatMap - dispose
  • 26. 95% WRITE A TITLE HERE First: What is a Fast-Fish? Alive or dead a fish is technically fast, when it is connected with an occupied ship or boat, by any medium at all controllable by the occupant oR Pratics Reactive thinking way Studying RxSwift components and operators You want to refactor yesterday’s code Personal Experience What I learned and what’s my feeling about RxSwift