SlideShare a Scribd company logo
ReactiveCocoa
functional reactive programming in iOS
Andrei Popa
A. current challenges in programming
- keeping state, inputs, asynchronous tasks, callback hell
B. how does Functional Reactive Programming solve them
- the functional aspect
- the reactive aspect
C. ReactiveCocoa - mature FRP implementation for iOS
D. Examples
- the input is all the sources of action for your app: button taps,
keyboard events, timer triggers, GPS events, web service
responses, etc.
- the output at any one time is the result of combining all inputs.
- ft (input) = output
- but unlike the classic input / output design, this input and
output happens more than once. It’s not just a single input -
work - output, the cycle continues while the app is open
first problem: state
first problem: state
And so our only tool for dealing with all these different things is state.
ReactiveCocoa - Functional Reactive Programming concepts in iOS
• obviously this is highly error prone
• to make matters worse, this type of code will often produce
bugs that are incredibly hard, if not impossible to identify in any
automated way
• state introduces complexity. And worse, it introduces
complexity that grows more than linearly with the size of our app
first problem: state
nondeterministic vs deterministic
nondeterministic vs deterministic
- most developers have experienced the problems of non-
determinism when a client calls in with a problem, but the
problem is not reproducible even by retracing the exact
same steps
- if the program was deterministic, then retracing those exact
steps would always produce the error, no exception
- for testing and quality assurance purposes, reproducibility
is essential
types of inputs - iOS
asynchronous operations
- network requests
- resource loading
- image processing
- bluetooth operations
- file I/O
What happens when several different asynchronous operations must
be executed in some set order (serialized)?
asynchronous operations
callback hell aka Pyramid of Doom
asynchronous operations
callback hell aka Pyramid of Doom
functional programming = stateless programming
- fundamental operation is the application of functions to
arguments.
- passing functions and blocks as objects
- there is no mutable state in functional programming
- f (input) = output , always produces the same output
given the same input. Always.
- it doesn’t rely / change on data outside the current function
functional programming = stateless programming
If we had machines that had infinite computational
power, what problems would we be able to solve?
- Alonzo Church developed λ - lambda calculus
Computability described via λ-calculus gave rise to Functional Programming
- Alan Turing developed Turing machine
Computability via Turing machines gave rise to Imperative Programming.
Church-Turing thesis: The notion of intuitive computability is
exactly captured by λ-definability or by Turing computability.
who is using functional programming ?
Some of the most complex systems written using Erlang:
- telecommunication and traffic control systems
- Ericsson (highly tolerant and scalable telecommunication switches)
- Facebook (Facebook chat backend)
- T-Mobile (advanced call control services)
- WhatsApp server
- average of 8 billion inbound messages and 12 billion outbound
messages a day
- WhatsApp scales up to more than a million connections on a single
box thanks to Erlang’s amazing scalability
reactive programming
In computing, reactive programming is a programming paradigm
oriented around data flows and the propagation of change.
We don’t care how it happens – just that we can rely on its truthfulness.
functional reactive programming
time-varying values
- lets us define our app in terms of the time-varying values and
ensures changes propagate as needed.
- the result of asynchronous work is really just a time-varying
value that only has a value once the work is done
- a UI element’s value could be seen as a time-varying value
that changes as the user interacts with it
- if my app is running on a mobile device, the device’s GPS
coordinates is a time-varying value
1. model any reaction to any event using signals
- wrap calls in RACSignal (ObjC) / SignalProducer (Swift)
2. manipulate, transform, combine values sent by signals
- map, filter, flattenMap, zip, concat, merge, …
- throttle, delay, repeat, then, take, distinctUntilChanged, …
- deliverOn(someThread), subscribeOn(someOtherThread)
- subscribe
ReactiveCocoa
provides a common interface for all events : signal
ReactiveCocoa
unifies all of Cocoa’s common patterns for asynchrony and event handling
ReactiveCocoa
unifies all of Cocoa’s common patterns for asynchrony and event handling
ReactiveCocoa - Functional Reactive Programming concepts in iOS
Examples
1) Take pictures
burst mode
2) Apply filter
3) Put frame
4) Send to back
for generating
animated GIF
- (RACSignal *) generateCats {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber>
subscriber) {
// my long async call ——————————————————————————-
[[MyCameraManager sharedInstance]
takePicturesBurstMode:^(UIImage *image, NSError *error) {
if (error) {
[subscriber sendError:error];
}
else {
[subscriber sendNext:image];
[subscriber sendCompleted];
}
}];
// ——————————————————————————————————————————————
return nil;
}];
}
1) take pictures
- (UIImage *) applyFilter(UIImage *) {
return ;
}
[[signalFactory generateCats]
map:^id(UIImage *cat) {
return applyFilter(cat);
}];
2) apply filter
- (UIImage *) putFrame(UIImage *)image {
return image ;
}
[[[signalFactory generateCats]
map:^id(UIImage *cat) {
return applyFilter(cat);
}]
map:^id(UIImage *cat) {
return putFrame(cat);
}];
3) put frame
[[[[[signalFactory generateCats]
map:^id(UIImage *cat) {
return applyFilter(cat);
}]
map:^id(UIImage *cat) {
return putFrame(cat);
}]
collect] // combine all next events into one NSArray
flattenMap:^RACStream *(NSArray *allCats) {
// [signalFactory sendAsyncToBackend:allCats] is a RACSignal
return [signalFactory sendAsyncToBackend:allCats];
}]; // this will still be a RACSignal
4) Send to back for generating animated GIF
[[[[[[signalFactory generateCats] // take pictures
map:^id(UIImage *cat) {
return applyFilter(cat);
}] // apply filter
map:^id(UIImage *cat) {
return putFrame(cat);
}]] // put frame
collect] // get all the processed images
flattenMap:^RACStream *(NSArray *allCats) {
return [signalFactory sendAsyncToBackend:allCats];
}] // send async call and wait for the result
// signal is started when someone subscribes
subscribeNext:^(UIImage *animatedGIF) {
// success!, display GIF
}
error:^(NSError *error) {
// error
}];
5) see the result
ReactiveCocoa - Functional Reactive Programming concepts in iOS
ReactiveCocoa - Functional Reactive Programming concepts in iOS
ReactiveCocoa - Functional Reactive Programming concepts in iOS
ReactiveCocoa
Bindings in MVVM architecture using RAC Signals
- http://rxmarbles.com/
- http://www.sprynthesis.com/2014/06/15/why-reactivecocoa/
- http://www.sprynthesis.com/2014/12/06/reactivecocoa-mvvm-
introduction/
- http://www.raywenderlich.com/62699/reactivecocoa-tutorial-pt1
- https://developers.soundcloud.com/blog/building-the-new-ios-app-a-
new-paradigm
- https://github.com/popaaaandrei/StarterProject_RACSwift2
The end. Thank you! Q&A

More Related Content

What's hot (20)

MVC
MVCMVC
MVC
Ravi Bansal
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
Ahmed Emad
 
Acrhitecture deisign pattern_MVC_MVP_MVVM
Acrhitecture deisign pattern_MVC_MVP_MVVMAcrhitecture deisign pattern_MVC_MVP_MVVM
Acrhitecture deisign pattern_MVC_MVP_MVVM
Dong-Ho Lee
 
Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01
Jennie Gajjar
 
Ui design patterns
Ui design patternsUi design patterns
Ui design patterns
Jorge Ortiz
 
Mvc, mvp, mvvm...
Mvc, mvp, mvvm...Mvc, mvp, mvvm...
Mvc, mvp, mvvm...
Yury Kisliak
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPF
S V
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
Jonas Follesø
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
M Ahsan Khan
 
MVC
MVCMVC
MVC
Iman Mehmandoust
 
Mvc pattern and implementation in java fair
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fair
Tech_MX
 
MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModel
Dareen Alhiyari
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
G ABHISEK
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
Wayne Tun Myint
 
Mvvm basics
Mvvm basicsMvvm basics
Mvvm basics
anusha kadimi
 
Model driven architecture
Model driven architectureModel driven architecture
Model driven architecture
Biruk Mamo
 
Design pattern
Design patternDesign pattern
Design pattern
Pawan Kumar Tiwari
 
What is MVC?
What is MVC?What is MVC?
What is MVC?
Dom Cimafranca
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
Ahmed Emad
 
Acrhitecture deisign pattern_MVC_MVP_MVVM
Acrhitecture deisign pattern_MVC_MVP_MVVMAcrhitecture deisign pattern_MVC_MVP_MVVM
Acrhitecture deisign pattern_MVC_MVP_MVVM
Dong-Ho Lee
 
Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01
Jennie Gajjar
 
Ui design patterns
Ui design patternsUi design patterns
Ui design patterns
Jorge Ortiz
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPF
S V
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
Jonas Follesø
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
M Ahsan Khan
 
Mvc pattern and implementation in java fair
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fair
Tech_MX
 
MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModel
Dareen Alhiyari
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
G ABHISEK
 
Model driven architecture
Model driven architectureModel driven architecture
Model driven architecture
Biruk Mamo
 

Viewers also liked (10)

Stanfy MadCode Meetup #9: Functional Programming 101 with Swift
Stanfy MadCode Meetup #9: Functional Programming 101 with SwiftStanfy MadCode Meetup #9: Functional Programming 101 with Swift
Stanfy MadCode Meetup #9: Functional Programming 101 with Swift
Stanfy
 
ReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better TogetherReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better Together
Colin Eberhardt
 
Reactive cocoa made Simple with Swift
Reactive cocoa made Simple with SwiftReactive cocoa made Simple with Swift
Reactive cocoa made Simple with Swift
Colin Eberhardt
 
Learn You a ReactiveCocoa for Great Good
Learn You a ReactiveCocoa for Great GoodLearn You a ReactiveCocoa for Great Good
Learn You a ReactiveCocoa for Great Good
Jason Larsen
 
ReactiveCocoa Goodness - Part I of II
ReactiveCocoa Goodness - Part I of IIReactiveCocoa Goodness - Part I of II
ReactiveCocoa Goodness - Part I of II
manuelmaly
 
ReactiveCocoa in Practice
ReactiveCocoa in PracticeReactiveCocoa in Practice
ReactiveCocoa in Practice
Outware Mobile
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
Florent Pillet
 
in in der 響應式編程
in in der 響應式編程in in der 響應式編程
in in der 響應式編程
景隆 張
 
ReactiveCocoa - TDC 2016
ReactiveCocoa - TDC 2016ReactiveCocoa - TDC 2016
ReactiveCocoa - TDC 2016
vinciusreal
 
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy
 
Stanfy MadCode Meetup #9: Functional Programming 101 with Swift
Stanfy MadCode Meetup #9: Functional Programming 101 with SwiftStanfy MadCode Meetup #9: Functional Programming 101 with Swift
Stanfy MadCode Meetup #9: Functional Programming 101 with Swift
Stanfy
 
ReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better TogetherReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better Together
Colin Eberhardt
 
Reactive cocoa made Simple with Swift
Reactive cocoa made Simple with SwiftReactive cocoa made Simple with Swift
Reactive cocoa made Simple with Swift
Colin Eberhardt
 
Learn You a ReactiveCocoa for Great Good
Learn You a ReactiveCocoa for Great GoodLearn You a ReactiveCocoa for Great Good
Learn You a ReactiveCocoa for Great Good
Jason Larsen
 
ReactiveCocoa Goodness - Part I of II
ReactiveCocoa Goodness - Part I of IIReactiveCocoa Goodness - Part I of II
ReactiveCocoa Goodness - Part I of II
manuelmaly
 
ReactiveCocoa in Practice
ReactiveCocoa in PracticeReactiveCocoa in Practice
ReactiveCocoa in Practice
Outware Mobile
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
Florent Pillet
 
in in der 響應式編程
in in der 響應式編程in in der 響應式編程
in in der 響應式編程
景隆 張
 
ReactiveCocoa - TDC 2016
ReactiveCocoa - TDC 2016ReactiveCocoa - TDC 2016
ReactiveCocoa - TDC 2016
vinciusreal
 
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy
 
Ad

Similar to ReactiveCocoa - Functional Reactive Programming concepts in iOS (20)

Moving towards Reactive Programming
Moving towards Reactive ProgrammingMoving towards Reactive Programming
Moving towards Reactive Programming
Deepak Shevani
 
When Web Services Go Bad
When Web Services Go BadWhen Web Services Go Bad
When Web Services Go Bad
Steve Loughran
 
React native
React nativeReact native
React native
Mohammed El Rafie Tarabay
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
Jonas Bandi
 
Concurrecny inf sharp
Concurrecny inf sharpConcurrecny inf sharp
Concurrecny inf sharp
Riccardo Terrell
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
jbandi
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
Coding Academy
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
Devin Bost
 
Is It The Cloud, The App, Or Just Me
Is It The Cloud, The App, Or Just MeIs It The Cloud, The App, Or Just Me
Is It The Cloud, The App, Or Just Me
Vik Chaudhary
 
Cloudsolutionday 2016: Docker & FAAS at getvero.com
Cloudsolutionday 2016: Docker & FAAS at getvero.comCloudsolutionday 2016: Docker & FAAS at getvero.com
Cloudsolutionday 2016: Docker & FAAS at getvero.com
AWS Vietnam Community
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one week
Dr. Felix Raab
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna Upreti
 
Mobile QA Metrics Risks and Automation Presentation By Yuval Golan
Mobile QA Metrics Risks and Automation Presentation  By Yuval GolanMobile QA Metrics Risks and Automation Presentation  By Yuval Golan
Mobile QA Metrics Risks and Automation Presentation By Yuval Golan
Yuval Golan
 
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
Pin-Ying Tu
 
Reactive web applications using MeteorJS
Reactive web applications using MeteorJSReactive web applications using MeteorJS
Reactive web applications using MeteorJS
NodeXperts
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
estefana2345678
 
[143]Inside fuse deview 2016
[143]Inside fuse   deview 2016[143]Inside fuse   deview 2016
[143]Inside fuse deview 2016
NAVER D2
 
Simulation as a Decision-Support Tool in Construction Project Management - Si...
Simulation as a Decision-Support Tool in Construction Project Management - Si...Simulation as a Decision-Support Tool in Construction Project Management - Si...
Simulation as a Decision-Support Tool in Construction Project Management - Si...
Muhtasim Fuad Rafid
 
Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)
Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)
Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)
VMware Tanzu
 
PWA
PWAPWA
PWA
Anuradha Malalasena
 
Moving towards Reactive Programming
Moving towards Reactive ProgrammingMoving towards Reactive Programming
Moving towards Reactive Programming
Deepak Shevani
 
When Web Services Go Bad
When Web Services Go BadWhen Web Services Go Bad
When Web Services Go Bad
Steve Loughran
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
Jonas Bandi
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
jbandi
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
Coding Academy
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
Devin Bost
 
Is It The Cloud, The App, Or Just Me
Is It The Cloud, The App, Or Just MeIs It The Cloud, The App, Or Just Me
Is It The Cloud, The App, Or Just Me
Vik Chaudhary
 
Cloudsolutionday 2016: Docker & FAAS at getvero.com
Cloudsolutionday 2016: Docker & FAAS at getvero.comCloudsolutionday 2016: Docker & FAAS at getvero.com
Cloudsolutionday 2016: Docker & FAAS at getvero.com
AWS Vietnam Community
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one week
Dr. Felix Raab
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna Upreti
 
Mobile QA Metrics Risks and Automation Presentation By Yuval Golan
Mobile QA Metrics Risks and Automation Presentation  By Yuval GolanMobile QA Metrics Risks and Automation Presentation  By Yuval Golan
Mobile QA Metrics Risks and Automation Presentation By Yuval Golan
Yuval Golan
 
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
Pin-Ying Tu
 
Reactive web applications using MeteorJS
Reactive web applications using MeteorJSReactive web applications using MeteorJS
Reactive web applications using MeteorJS
NodeXperts
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
estefana2345678
 
[143]Inside fuse deview 2016
[143]Inside fuse   deview 2016[143]Inside fuse   deview 2016
[143]Inside fuse deview 2016
NAVER D2
 
Simulation as a Decision-Support Tool in Construction Project Management - Si...
Simulation as a Decision-Support Tool in Construction Project Management - Si...Simulation as a Decision-Support Tool in Construction Project Management - Si...
Simulation as a Decision-Support Tool in Construction Project Management - Si...
Muhtasim Fuad Rafid
 
Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)
Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)
Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)
VMware Tanzu
 
Ad

Recently uploaded (20)

7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf
Minuscule Technologies
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | BluebashMCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
Bluebash
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Dancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptxDancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptx
Elliott Richmond
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf
Minuscule Technologies
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | BluebashMCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
Bluebash
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Dancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptxDancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptx
Elliott Richmond
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 

ReactiveCocoa - Functional Reactive Programming concepts in iOS

  • 2. A. current challenges in programming - keeping state, inputs, asynchronous tasks, callback hell B. how does Functional Reactive Programming solve them - the functional aspect - the reactive aspect C. ReactiveCocoa - mature FRP implementation for iOS D. Examples
  • 3. - the input is all the sources of action for your app: button taps, keyboard events, timer triggers, GPS events, web service responses, etc. - the output at any one time is the result of combining all inputs. - ft (input) = output - but unlike the classic input / output design, this input and output happens more than once. It’s not just a single input - work - output, the cycle continues while the app is open first problem: state
  • 4. first problem: state And so our only tool for dealing with all these different things is state.
  • 6. • obviously this is highly error prone • to make matters worse, this type of code will often produce bugs that are incredibly hard, if not impossible to identify in any automated way • state introduces complexity. And worse, it introduces complexity that grows more than linearly with the size of our app first problem: state
  • 8. nondeterministic vs deterministic - most developers have experienced the problems of non- determinism when a client calls in with a problem, but the problem is not reproducible even by retracing the exact same steps - if the program was deterministic, then retracing those exact steps would always produce the error, no exception - for testing and quality assurance purposes, reproducibility is essential
  • 10. asynchronous operations - network requests - resource loading - image processing - bluetooth operations - file I/O What happens when several different asynchronous operations must be executed in some set order (serialized)?
  • 13. functional programming = stateless programming - fundamental operation is the application of functions to arguments. - passing functions and blocks as objects - there is no mutable state in functional programming - f (input) = output , always produces the same output given the same input. Always. - it doesn’t rely / change on data outside the current function
  • 14. functional programming = stateless programming
  • 15. If we had machines that had infinite computational power, what problems would we be able to solve? - Alonzo Church developed λ - lambda calculus Computability described via λ-calculus gave rise to Functional Programming - Alan Turing developed Turing machine Computability via Turing machines gave rise to Imperative Programming. Church-Turing thesis: The notion of intuitive computability is exactly captured by λ-definability or by Turing computability.
  • 16. who is using functional programming ? Some of the most complex systems written using Erlang: - telecommunication and traffic control systems - Ericsson (highly tolerant and scalable telecommunication switches) - Facebook (Facebook chat backend) - T-Mobile (advanced call control services) - WhatsApp server - average of 8 billion inbound messages and 12 billion outbound messages a day - WhatsApp scales up to more than a million connections on a single box thanks to Erlang’s amazing scalability
  • 17. reactive programming In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. We don’t care how it happens – just that we can rely on its truthfulness.
  • 18. functional reactive programming time-varying values - lets us define our app in terms of the time-varying values and ensures changes propagate as needed. - the result of asynchronous work is really just a time-varying value that only has a value once the work is done - a UI element’s value could be seen as a time-varying value that changes as the user interacts with it - if my app is running on a mobile device, the device’s GPS coordinates is a time-varying value
  • 19. 1. model any reaction to any event using signals - wrap calls in RACSignal (ObjC) / SignalProducer (Swift) 2. manipulate, transform, combine values sent by signals - map, filter, flattenMap, zip, concat, merge, … - throttle, delay, repeat, then, take, distinctUntilChanged, … - deliverOn(someThread), subscribeOn(someOtherThread) - subscribe ReactiveCocoa provides a common interface for all events : signal
  • 20. ReactiveCocoa unifies all of Cocoa’s common patterns for asynchrony and event handling
  • 21. ReactiveCocoa unifies all of Cocoa’s common patterns for asynchrony and event handling
  • 24. 1) Take pictures burst mode 2) Apply filter 3) Put frame 4) Send to back for generating animated GIF
  • 25. - (RACSignal *) generateCats { return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { // my long async call ——————————————————————————- [[MyCameraManager sharedInstance] takePicturesBurstMode:^(UIImage *image, NSError *error) { if (error) { [subscriber sendError:error]; } else { [subscriber sendNext:image]; [subscriber sendCompleted]; } }]; // —————————————————————————————————————————————— return nil; }]; } 1) take pictures
  • 26. - (UIImage *) applyFilter(UIImage *) { return ; } [[signalFactory generateCats] map:^id(UIImage *cat) { return applyFilter(cat); }]; 2) apply filter
  • 27. - (UIImage *) putFrame(UIImage *)image { return image ; } [[[signalFactory generateCats] map:^id(UIImage *cat) { return applyFilter(cat); }] map:^id(UIImage *cat) { return putFrame(cat); }]; 3) put frame
  • 28. [[[[[signalFactory generateCats] map:^id(UIImage *cat) { return applyFilter(cat); }] map:^id(UIImage *cat) { return putFrame(cat); }] collect] // combine all next events into one NSArray flattenMap:^RACStream *(NSArray *allCats) { // [signalFactory sendAsyncToBackend:allCats] is a RACSignal return [signalFactory sendAsyncToBackend:allCats]; }]; // this will still be a RACSignal 4) Send to back for generating animated GIF
  • 29. [[[[[[signalFactory generateCats] // take pictures map:^id(UIImage *cat) { return applyFilter(cat); }] // apply filter map:^id(UIImage *cat) { return putFrame(cat); }]] // put frame collect] // get all the processed images flattenMap:^RACStream *(NSArray *allCats) { return [signalFactory sendAsyncToBackend:allCats]; }] // send async call and wait for the result // signal is started when someone subscribes subscribeNext:^(UIImage *animatedGIF) { // success!, display GIF } error:^(NSError *error) { // error }]; 5) see the result
  • 33. ReactiveCocoa Bindings in MVVM architecture using RAC Signals
  • 34. - http://rxmarbles.com/ - http://www.sprynthesis.com/2014/06/15/why-reactivecocoa/ - http://www.sprynthesis.com/2014/12/06/reactivecocoa-mvvm- introduction/ - http://www.raywenderlich.com/62699/reactivecocoa-tutorial-pt1 - https://developers.soundcloud.com/blog/building-the-new-ios-app-a- new-paradigm - https://github.com/popaaaandrei/StarterProject_RACSwift2 The end. Thank you! Q&A