SlideShare a Scribd company logo
1 of 36
Download to read offline
Introduction to
Functional Reactive
Programming
EliaszSawicki.com ( @EliSawic )
Functional Reactive
Programming
EliaszSawicki.com ( @EliSawic )
Streams
EliaszSawicki.com ( @EliSawic )
Stream
EliaszSawicki.com ( @EliSawic )
Arrays
let values = [1, 2, 3, 4]
let doubledValues = values.map { $0 * 2 }
let higherThanTwo = values.filter { $0 > 2 }
let sum = values.reduce(0, +)
EliaszSawicki.com ( @EliSawic )
Filter
EliaszSawicki.com ( @EliSawic )
Combine Latest
EliaszSawicki.com ( @EliSawic )
Chaining manipulations
let names = nameField.reactive.text
EliaszSawicki.com ( @EliSawic )
Chaining manipulations
names.filter { $0.characters.count >= 3}
EliaszSawicki.com ( @EliSawic )
Chaining manipulations
names.filter { $0.characters.count >= 3}
.map { return "Dear" + $0 }
EliaszSawicki.com ( @EliSawic )
Chaining manipulations
let prefixedNames = names.filter { $0.characters.count >= 3}
.map { return "Dear" + $0 }
let combined = combineLatest(prefixedNames, surnames)
combined.observeValues { prefixedNames, surname in
print("Form input is (prefixedNames) (surname)")
}
EliaszSawicki.com ( @EliSawic )
www.rxmarbles.com
EliaszSawicki.com ( @EliSawic )
ReactiveSwift
EliaszSawicki.com ( @EliSawic )
Events flow
EliaszSawicki.com ( @EliSawic )
Non-Terminating
• Next
EliaszSawicki.com ( @EliSawic )
Terminating
• Completed
• Failed
• Interrupted (Reactive Cocoa)
EliaszSawicki.com ( @EliSawic )
This screen is a signal
EliaszSawicki.com ( @EliSawic )
Represents events
over time
EliaszSawicki.com ( @EliSawic )
Observe
EliaszSawicki.com ( @EliSawic )
EliaszSawicki.com ( @EliSawic )
If you don't observe,
it's gone
EliaszSawicki.com ( @EliSawic )
Observing
presentation.observeValues { idea in
remember(idea: idea)
}
presentation.observeCompleted {
print("Time for a break")
}
EliaszSawicki.com ( @EliSawic )
Signal producer
EliaszSawicki.com ( @EliSawic )
Represents a tasks
EliaszSawicki.com ( @EliSawic )
Does not start it's
work if not asked
EliaszSawicki.com ( @EliSawic )
Producing
presenter.startWithSignal { (signal, _) in
signal.observeValues { idea in
print(idea)
}
signal.observeCompleted {
print("Time for a break")
}
}
EliaszSawicki.com ( @EliSawic )
Hot vs Cold
EliaszSawicki.com ( @EliSawic )
Signal SignalProducer
presentation.observeValues presentation.startWithValues
EliaszSawicki.com ( @EliSawic )
Signal SignalProducer
presentation.observeValues presentation.startWithValues
emits values all the time waits for your request
EliaszSawicki.com ( @EliSawic )
Properties
EliaszSawicki.com ( @EliSawic )
Bindings
EliaszSawicki.com ( @EliSawic )
Binding example
let (slides, _) = Signal<Slide, NoError>.pipe()
label.reactive.text <~ slides.map { return "Slide: ($0.number)" }
EliaszSawicki.com ( @EliSawic )
Memory Management
EliaszSawicki.com ( @EliSawic )
Disposables
EliaszSawicki.com ( @EliSawic )
Free your memory
let disposable = signal.observeValues { value in
...
}
deinit {
disposable.dispose()
}
EliaszSawicki.com ( @EliSawic )
FUNctional reactive
programming
EliaszSawicki.com ( @EliSawic )

More Related Content

Viewers also liked

المرور عبر حارس البوابه و الوصول الى متخذ القرار
المرور عبر حارس البوابه و الوصول الى متخذ القرارالمرور عبر حارس البوابه و الوصول الى متخذ القرار
المرور عبر حارس البوابه و الوصول الى متخذ القرارAshraf Osman
 
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...CINEC Campus
 
Instinto, sexo y sexualidad
Instinto, sexo y sexualidadInstinto, sexo y sexualidad
Instinto, sexo y sexualidadJesus Villasmil
 
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...Harvard Web Working Group
 
Problematicas emergentes
Problematicas emergentesProblematicas emergentes
Problematicas emergentescursavirtual
 
オブジェクト指向
オブジェクト指向オブジェクト指向
オブジェクト指向和樹 川端
 
Edudirectores - El desarrollo de la función directiva - 1ª sesión presencial
Edudirectores - El desarrollo de la función directiva - 1ª sesión presencialEdudirectores - El desarrollo de la función directiva - 1ª sesión presencial
Edudirectores - El desarrollo de la función directiva - 1ª sesión presencialJuanfra Álvarez Herrero
 
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...Codemotion
 
成果を達成するためのデザインプロセス
成果を達成するためのデザインプロセス成果を達成するためのデザインプロセス
成果を達成するためのデザインプロセスYuudai Tachibana
 
Techniques & Tools for Training Strong Distributed Teams
Techniques & Tools for Training Strong Distributed TeamsTechniques & Tools for Training Strong Distributed Teams
Techniques & Tools for Training Strong Distributed TeamsSococo
 
conservation and rewarding biodiversity conservation Trondheim 05-10-gupta-...
conservation and rewarding biodiversity conservation Trondheim   05-10-gupta-...conservation and rewarding biodiversity conservation Trondheim   05-10-gupta-...
conservation and rewarding biodiversity conservation Trondheim 05-10-gupta-...Dr Anil Gupta
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiJérémy Derussé
 
Putting Fuel on the Fire - Advocacy in the North
Putting Fuel on the Fire - Advocacy in the NorthPutting Fuel on the Fire - Advocacy in the North
Putting Fuel on the Fire - Advocacy in the NorthCitizen Network
 
10 Questions For Your Scrum Master Interview
10 Questions For Your Scrum Master Interview10 Questions For Your Scrum Master Interview
10 Questions For Your Scrum Master InterviewDavid Bland
 
Ανακαίνιση φαρμακείου
Ανακαίνιση φαρμακείουΑνακαίνιση φαρμακείου
Ανακαίνιση φαρμακείουdomi anakainisi
 
5 Tips To Choose A Good QuickBooks Hosting Provider
5 Tips To Choose A Good QuickBooks Hosting Provider5 Tips To Choose A Good QuickBooks Hosting Provider
5 Tips To Choose A Good QuickBooks Hosting ProviderNishant Kadian
 

Viewers also liked (19)

المرور عبر حارس البوابه و الوصول الى متخذ القرار
المرور عبر حارس البوابه و الوصول الى متخذ القرارالمرور عبر حارس البوابه و الوصول الى متخذ القرار
المرور عبر حارس البوابه و الوصول الى متخذ القرار
 
Manejo de la preeclampsia y vómitos en el embarazo
Manejo de la preeclampsia y vómitos en el embarazoManejo de la preeclampsia y vómitos en el embarazo
Manejo de la preeclampsia y vómitos en el embarazo
 
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
 
Instinto, sexo y sexualidad
Instinto, sexo y sexualidadInstinto, sexo y sexualidad
Instinto, sexo y sexualidad
 
Effective Code Review
Effective Code ReviewEffective Code Review
Effective Code Review
 
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
 
Problematicas emergentes
Problematicas emergentesProblematicas emergentes
Problematicas emergentes
 
オブジェクト指向
オブジェクト指向オブジェクト指向
オブジェクト指向
 
Edudirectores - El desarrollo de la función directiva - 1ª sesión presencial
Edudirectores - El desarrollo de la función directiva - 1ª sesión presencialEdudirectores - El desarrollo de la función directiva - 1ª sesión presencial
Edudirectores - El desarrollo de la función directiva - 1ª sesión presencial
 
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
 
成果を達成するためのデザインプロセス
成果を達成するためのデザインプロセス成果を達成するためのデザインプロセス
成果を達成するためのデザインプロセス
 
Techniques & Tools for Training Strong Distributed Teams
Techniques & Tools for Training Strong Distributed TeamsTechniques & Tools for Training Strong Distributed Teams
Techniques & Tools for Training Strong Distributed Teams
 
conservation and rewarding biodiversity conservation Trondheim 05-10-gupta-...
conservation and rewarding biodiversity conservation Trondheim   05-10-gupta-...conservation and rewarding biodiversity conservation Trondheim   05-10-gupta-...
conservation and rewarding biodiversity conservation Trondheim 05-10-gupta-...
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
Using Open Data to fuel LegalTech Innovation
Using Open Data to fuel LegalTech InnovationUsing Open Data to fuel LegalTech Innovation
Using Open Data to fuel LegalTech Innovation
 
Putting Fuel on the Fire - Advocacy in the North
Putting Fuel on the Fire - Advocacy in the NorthPutting Fuel on the Fire - Advocacy in the North
Putting Fuel on the Fire - Advocacy in the North
 
10 Questions For Your Scrum Master Interview
10 Questions For Your Scrum Master Interview10 Questions For Your Scrum Master Interview
10 Questions For Your Scrum Master Interview
 
Ανακαίνιση φαρμακείου
Ανακαίνιση φαρμακείουΑνακαίνιση φαρμακείου
Ανακαίνιση φαρμακείου
 
5 Tips To Choose A Good QuickBooks Hosting Provider
5 Tips To Choose A Good QuickBooks Hosting Provider5 Tips To Choose A Good QuickBooks Hosting Provider
5 Tips To Choose A Good QuickBooks Hosting Provider
 

Similar to iOSCon

Introduction To Functional Reactive Programming Poznan
Introduction To Functional Reactive Programming PoznanIntroduction To Functional Reactive Programming Poznan
Introduction To Functional Reactive Programming PoznanEliasz Sawicki
 
Introduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingIntroduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingEliasz Sawicki
 
Akka.NET streams and reactive streams
Akka.NET streams and reactive streamsAkka.NET streams and reactive streams
Akka.NET streams and reactive streamsBartosz Sypytkowski
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Anton Arhipov
 
JDD 2016 - Pawel Byszewski - Kotlin, why?
JDD 2016 - Pawel Byszewski - Kotlin, why?JDD 2016 - Pawel Byszewski - Kotlin, why?
JDD 2016 - Pawel Byszewski - Kotlin, why?PROIDEA
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
 
Less ismorewithcoffeescript webdirectionsfeb2012
Less ismorewithcoffeescript webdirectionsfeb2012Less ismorewithcoffeescript webdirectionsfeb2012
Less ismorewithcoffeescript webdirectionsfeb2012Jo Cranford
 
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС2ГИС Технологии
 
Практическое применения Akka Streams
Практическое применения Akka StreamsПрактическое применения Akka Streams
Практическое применения Akka StreamsAlexey Romanchuk
 
Next generation actors with Akka
Next generation actors with AkkaNext generation actors with Akka
Next generation actors with AkkaJohan Andrén
 
Concept of Stream API Java 1.8
Concept of Stream API Java 1.8Concept of Stream API Java 1.8
Concept of Stream API Java 1.8InnovationM
 
Scalactic Collections
Scalactic CollectionsScalactic Collections
Scalactic Collectionsbvenners
 
ReactiveCocoa workshop
ReactiveCocoa workshopReactiveCocoa workshop
ReactiveCocoa workshopEliasz Sawicki
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivitynklmish
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 

Similar to iOSCon (20)

Introduction To Functional Reactive Programming Poznan
Introduction To Functional Reactive Programming PoznanIntroduction To Functional Reactive Programming Poznan
Introduction To Functional Reactive Programming Poznan
 
Code europe
Code europeCode europe
Code europe
 
Introduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingIntroduction to Functional Reactive Programming
Introduction to Functional Reactive Programming
 
Akka.NET streams and reactive streams
Akka.NET streams and reactive streamsAkka.NET streams and reactive streams
Akka.NET streams and reactive streams
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
 
Kotlin, why?
Kotlin, why?Kotlin, why?
Kotlin, why?
 
JDD 2016 - Pawel Byszewski - Kotlin, why?
JDD 2016 - Pawel Byszewski - Kotlin, why?JDD 2016 - Pawel Byszewski - Kotlin, why?
JDD 2016 - Pawel Byszewski - Kotlin, why?
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0
 
Less ismorewithcoffeescript webdirectionsfeb2012
Less ismorewithcoffeescript webdirectionsfeb2012Less ismorewithcoffeescript webdirectionsfeb2012
Less ismorewithcoffeescript webdirectionsfeb2012
 
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
 
Практическое применения Akka Streams
Практическое применения Akka StreamsПрактическое применения Akka Streams
Практическое применения Akka Streams
 
Next generation actors with Akka
Next generation actors with AkkaNext generation actors with Akka
Next generation actors with Akka
 
Concept of Stream API Java 1.8
Concept of Stream API Java 1.8Concept of Stream API Java 1.8
Concept of Stream API Java 1.8
 
Scalactic Collections
Scalactic CollectionsScalactic Collections
Scalactic Collections
 
ReactiveCocoa workshop
ReactiveCocoa workshopReactiveCocoa workshop
ReactiveCocoa workshop
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
 
Kotlin Backstage
Kotlin BackstageKotlin Backstage
Kotlin Backstage
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 

More from Eliasz Sawicki

Eliasz sawickimeetupit
Eliasz sawickimeetupitEliasz sawickimeetupit
Eliasz sawickimeetupitEliasz Sawicki
 
Developing more in less time
Developing more in less timeDeveloping more in less time
Developing more in less timeEliasz Sawicki
 
The art-of-developing-more-in-less-time-berlin
The art-of-developing-more-in-less-time-berlinThe art-of-developing-more-in-less-time-berlin
The art-of-developing-more-in-less-time-berlinEliasz Sawicki
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react nativeEliasz Sawicki
 
Doing more in less time - Mobiconf
Doing more in less time - MobiconfDoing more in less time - Mobiconf
Doing more in less time - MobiconfEliasz Sawicki
 
Time traveling with ReSwift
Time traveling with ReSwiftTime traveling with ReSwift
Time traveling with ReSwiftEliasz Sawicki
 
ReSwift CocoaHeads Tricity
ReSwift CocoaHeads TricityReSwift CocoaHeads Tricity
ReSwift CocoaHeads TricityEliasz Sawicki
 

More from Eliasz Sawicki (9)

Redux - 4Developers
Redux - 4DevelopersRedux - 4Developers
Redux - 4Developers
 
Eliasz sawickimeetupit
Eliasz sawickimeetupitEliasz sawickimeetupit
Eliasz sawickimeetupit
 
Developing more in less time
Developing more in less timeDeveloping more in less time
Developing more in less time
 
The art-of-developing-more-in-less-time-berlin
The art-of-developing-more-in-less-time-berlinThe art-of-developing-more-in-less-time-berlin
The art-of-developing-more-in-less-time-berlin
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react native
 
Doing more in less time - Mobiconf
Doing more in less time - MobiconfDoing more in less time - Mobiconf
Doing more in less time - Mobiconf
 
Time traveling with ReSwift
Time traveling with ReSwiftTime traveling with ReSwift
Time traveling with ReSwift
 
Calabash
CalabashCalabash
Calabash
 
ReSwift CocoaHeads Tricity
ReSwift CocoaHeads TricityReSwift CocoaHeads Tricity
ReSwift CocoaHeads Tricity
 

iOSCon