SlideShare a Scribd company logo
Pavlo Zakharov
Reactive Cocoa:
Paradigm shift.
- What is Reactive functional Paradigm?
- Why consider using ReactiveCocoa?
- RAC Signal.Unifying all of Cocoa’s common
patterns.
- RAC and concurrency.
- Implementing MVVM design pattern on iOS
with RAC.
What is Reactive Functional
Programming?
Functional reactive programming (FRP) is a programming paradigm for
reactive programming (asynchronous dataflow programming) using the building
blocks of functional programming (e.g. map, reduce, filter). FRP has been used for
programming graphical user interfaces (GUIs), robotics, and music, aiming to
simplify these problems by explicitly modelling time. (c) Wikipedia
Reactive+Functional:
❖ Static/Dynamic data flow.(Programming based on
Events)
❖ (Functional Blocks) Functions passed as arguments to
functions.
Cocoa Events
❖ Delegation
❖ KVO
❖ Target - Action
❖ Callback Blocks
❖ NSNotifications
}RacSignal
RACSignal
❖ Next
❖ Error
❖ Completed
Ray Signal emits:
[self.searchText.rac_textSignal subscribeNext:^(id x) {
NSLog(@"Next ocured");
}error:^(NSError *error) {
NSLog(@"Error ocured");
}completed:^{
NSLog(@"Completed");
}];
Signal can have one or multiple subscribers
Events
Event flow:
CompletedCompleted
NextNext
NextNext
NextNext ErrorError
NextNext NextNext …
Reactive Operations
❖ Map
❖ Throttle
❖ Skip
❖ Filter
❖ DeliverOn
❖ more…
Operations don’t care about
signal source.
Map
❖ Transforms the value of the event(As transformed value
as input signal can be literally anything)
RACSignal *mySignal = [textSignal map:^id(NSString *text) {
return @(text.length>3);
}];
[mySignal subscribeNext:^(NSNumber* x) {
if ([x boolValue]) {
//...
}
}];
Combine
❖ Combines two RAC Events(Next Emits when one of
combined events occurs).
RACSignal *switch1Signal = …
RACSignal *switch2Signal = …
RACSignal *both = [RACSignal combineLatest:@[switch1Signal,switch2Signal] reduce:^id(NSNumber *switch1,
NSNumber *switch2){
return @([switch1 boolValue] && [switch2 boolValue]);
}];
[both subscribeNext:^(id x) {
if([x boolValue]){
NSLog(@"Both");
}
}];
Filter
❖ Event will be emitted only if the condition is satisfied.
[[self.usernameTextField.rac_textSignal filter:^BOOL(id value) {
return (((NSString*)value).length>3);
}]subscribeNext:^(id x) {
NSLog(@"do stuff");
}];
Throttle
❖ If event occurrence once more within time interval
specified event wouldn’t be emitted.(Extremely useful
for locking buttons to prevent speed clicking)
[[[self.usernameTextField.rac_textSignal filter:^BOOL(id value) {
return (((NSString*)value).length>3);
}]throttle:0.5]subscribeNext:^(id x) {
NSLog(@"do stuff");
}];
Deliver On
❖ The block will be executed on thread specified (For
example for UI stuff on main thread)
[[[self.usernameTextField.rac_textSignal filter:^BOOL(id value) {
return (((NSString*)value).length>3);
}] deliverOn:[RACScheduler mainThreadScheduler]]subscribeNext:^(id x) {
NSLog(@"do UI stuff");
}];
How to mix reactive code with
non-reactive?
Option one: doNext block
❖ doNext Block will be executed before subscriberBlock
will be called.This is the good place for reactive code.
[[[self.signInButton
rac_signalForControlEvents:UIControlEventTouchUpInside]
doNext:^(id x) {
//put your non-reactive code here
}]
subscribeNext:^(NSNumber *signedIn) {
//do stuff
}];}
Wrap non-reactive code to
reactive
❖ Method will create signal which can emit
next/error/completed event based on your non-
reactive conditions.
-(RACSignal *)switchSignal{
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
(self.switch1.isOn)?[subscriber sendNext:@(YES)] : [subscriber sendNext:@(NO)];
return nil;
}];
}
//.
//.
//.
[[self switchSignal]subscribeNext:^(id x) {
//doStuff
}];
Bind Signal to UIEvent
❖ Every time touchUpInside event occurs next event will
be emitted;
RACSignal *mySignal = [self.getButton rac_signalForControlEvents:UIControlEventTouchUpInside]
Avoid Retain cycles
❖ Accessing self in block can cause retain cycle and
memory leak.Use __weak self to prevent it.
@weakify(self);
[self.searchText.rac_textSignal subscribeNext:^(id x) {
@strongify(self);
// self.smth = smth
}error:^(NSError *error) {
@strongify(self);
// self.smthElse = smth
}completed:^{
@strongify(self);
// self.smthReallyDifferent = smth
}];
ModelViewViewModel
ViewModel
❖ ViewModel which is a special type of model that
represents the UI state of the application
ViewView ViewModelViewModel ModelModel
ViewView ViewModelViewModel ModelModelControllerController
Binding
❖ Binds textField.text to the property in ViewModel.
Every time property changes text will change as well.
(WPF implementation is shown on the right)
RAC(self.searchText,text) =
self.myString;
 <TextBlock TextContent=”{Binding
Path=Description}” />
~
Why should i use RAC?
❖ Unified interface for all Cocoa events.
❖ Less code in comparison with non-reactive code.
❖ No massive ViewControllers with complicated
relationships.
❖ Easy work with concurrency.
❖ No complicated “States” needed.
Some Disadvantages
❖ Debug Hell.
❖ Little overhead
❖ Weird syntax.(But you will get used to it)
Resources
❖ https://github.com/ReactiveCocoa/ReactiveCocoa
❖ http://www.raywenderlich.com
❖ http://blog.scottlogic.com/2014/07/24/mvvm-reactivecoc
❖ https://www.youtube.com/watch?v=DgdISd1Qc48
❖ https://www.youtube.com/watch?v=fWV7xyN5CR8
❖ https://github.com/ZakharovPaul/RacDemo.git
Questions?
Thank you
Skype: c1ark.
E-mail:
zakharov.paul@live.com

More Related Content

PDF
An Introduction to Reactive Cocoa
PDF
Learn You a ReactiveCocoa for Great Good
PDF
Functional Reactive Programming (CocoaHeads Bratislava)
PDF
ReactiveCocoa Goodness - Part I of II
PDF
Reactive cocoa made Simple with Swift
PDF
ReactiveCocoa in Practice
PPTX
Declarative JavaScript concepts and implemetation
PPT
My first experience with lambda expressions in java
An Introduction to Reactive Cocoa
Learn You a ReactiveCocoa for Great Good
Functional Reactive Programming (CocoaHeads Bratislava)
ReactiveCocoa Goodness - Part I of II
Reactive cocoa made Simple with Swift
ReactiveCocoa in Practice
Declarative JavaScript concepts and implemetation
My first experience with lambda expressions in java

What's hot (20)

PPTX
Introduction to RxJava on Android
PDF
Dynamic pricing of Lyft rides using streaming
PPTX
Linq
PDF
Net framework
PDF
Grokking Techtalk #38: Escape Analysis in Go compiler
PPTX
Linq to sql
PPTX
Linq to sql
ODP
Modern Java Features
PDF
My Gentle Introduction to RxJS
PDF
cb streams - gavin pickin
PDF
Streaming your Lyft Ride Prices - Flink Forward SF 2019
PPSX
Functional patterns and techniques in C#
PPTX
Link quries
ODP
JavaScript global object, execution contexts & closures
PPT
Reactive cocoa
PPT
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
PPT
Understanding linq
PPTX
Reactive Extensions for JavaScript
PPTX
Intro to Akka Streams
Introduction to RxJava on Android
Dynamic pricing of Lyft rides using streaming
Linq
Net framework
Grokking Techtalk #38: Escape Analysis in Go compiler
Linq to sql
Linq to sql
Modern Java Features
My Gentle Introduction to RxJS
cb streams - gavin pickin
Streaming your Lyft Ride Prices - Flink Forward SF 2019
Functional patterns and techniques in C#
Link quries
JavaScript global object, execution contexts & closures
Reactive cocoa
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Understanding linq
Reactive Extensions for JavaScript
Intro to Akka Streams
Ad

Viewers also liked (20)

PDF
Lviv MD Day 2015 Софія Дунаєва "Health care Data visualization"
PPTX
Андрій Чорний "Формула успішного інтернет-магазину"
PPTX
PMday 2015. Андрій Мудрий “How to Manage Team in Sri Lanka”
PPTX
PMday 2015. Тетяна Голубєва “Гнучкість в менеджменті – що це і як цим користу...
PPTX
Lviv GameDev Mixer Ростислав Чайка "Як програмiсту зробити свою першу iграшку"
PPTX
Lviv GameDev Mixer Синява Олександр "The Big Journey - маленька історія про в...
PPTX
Lviv MD Day 2015 Олександр Краковецький "Universal Windows Platform Bridges д...
PPTX
PMday 2015. Сергій Поволяшко “Історія про впровадження Процесу”
PDF
Lviv MD Day 2015 Меляницький Владислав "Гібридні програми на JavaScript"
PDF
PMday 2015. Максим Вишнівецький “Що робити, якщо ваш замовник кенгуру? А якщо...
PPTX
SMM Горінь Євстахій "Корпоративний блог: як і навіщо його вести"
PPTX
Lviv PM Club Голубєва Тетяна "Правильний світогляд, як головна якість менеджера"
PDF
iCamp 2015. Катерина Золотарьова “SEO тренди 2016: зрозуміти та застосувати”
PPTX
iCamp 2015. Людмила Макаренко “Лабіринти мозку, погляд рекламіста”
PDF
Lviv Freelance Club #37 Ivan Koval "Історія успіху: програміст, тім лідер, фр...
PPTX
iCamp 2015. Олексій Яновський “Як правильно укласти електронний договір по за...
PDF
Lviv MD Day 2015 Мобільний додаток "Password Hacking"
PDF
Вебінар "Зона відповідальності продуктового фахівця в проекті"
PDF
PMday 2015. Юрій Козій “Менеджерські граблі, або Фейл – найкращий вчитель”
PPTX
PMday Максим Бардега “Чи потрібно ставати PM-ом і якщо так, то навіщо”
Lviv MD Day 2015 Софія Дунаєва "Health care Data visualization"
Андрій Чорний "Формула успішного інтернет-магазину"
PMday 2015. Андрій Мудрий “How to Manage Team in Sri Lanka”
PMday 2015. Тетяна Голубєва “Гнучкість в менеджменті – що це і як цим користу...
Lviv GameDev Mixer Ростислав Чайка "Як програмiсту зробити свою першу iграшку"
Lviv GameDev Mixer Синява Олександр "The Big Journey - маленька історія про в...
Lviv MD Day 2015 Олександр Краковецький "Universal Windows Platform Bridges д...
PMday 2015. Сергій Поволяшко “Історія про впровадження Процесу”
Lviv MD Day 2015 Меляницький Владислав "Гібридні програми на JavaScript"
PMday 2015. Максим Вишнівецький “Що робити, якщо ваш замовник кенгуру? А якщо...
SMM Горінь Євстахій "Корпоративний блог: як і навіщо його вести"
Lviv PM Club Голубєва Тетяна "Правильний світогляд, як головна якість менеджера"
iCamp 2015. Катерина Золотарьова “SEO тренди 2016: зрозуміти та застосувати”
iCamp 2015. Людмила Макаренко “Лабіринти мозку, погляд рекламіста”
Lviv Freelance Club #37 Ivan Koval "Історія успіху: програміст, тім лідер, фр...
iCamp 2015. Олексій Яновський “Як правильно укласти електронний договір по за...
Lviv MD Day 2015 Мобільний додаток "Password Hacking"
Вебінар "Зона відповідальності продуктового фахівця в проекті"
PMday 2015. Юрій Козій “Менеджерські граблі, або Фейл – найкращий вчитель”
PMday Максим Бардега “Чи потрібно ставати PM-ом і якщо так, то навіщо”
Ad

Similar to Lviv MD Day 2015 Павло Захаров "Reactive cocoa: paradigm shift" (20)

PDF
Reactive cocoa
PDF
Reactive Cocoa
PDF
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
PPTX
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
PPTX
Apple.combine
PDF
Play framework
PDF
Functional Reactive Programming dengan ReactiveCocoa
PDF
Reactive cocoa cocoaheadsbe_2014
PDF
NGRX Apps in Depth
PDF
Spring 5 Webflux - Advances in Java 2018
ODP
Presentation - Course about JavaFX
PPTX
Event-driven IO server-side JavaScript environment based on V8 Engine
PPT
PDF
F# and SignalR for a FastWeb
PDF
JSAnkara Swift v React Native
PDF
GTS Episode 1: Reactive programming in the wild
PDF
Functional Web Development
ODP
Asynchronous I/O in NodeJS - new standard or challenges?
PDF
Linguistic Abstraction for the Web
ODP
Node js
Reactive cocoa
Reactive Cocoa
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
Apple.combine
Play framework
Functional Reactive Programming dengan ReactiveCocoa
Reactive cocoa cocoaheadsbe_2014
NGRX Apps in Depth
Spring 5 Webflux - Advances in Java 2018
Presentation - Course about JavaFX
Event-driven IO server-side JavaScript environment based on V8 Engine
F# and SignalR for a FastWeb
JSAnkara Swift v React Native
GTS Episode 1: Reactive programming in the wild
Functional Web Development
Asynchronous I/O in NodeJS - new standard or challenges?
Linguistic Abstraction for the Web
Node js

More from Lviv Startup Club (20)

PDF
Maksym Vyshnivetskyi: PMO KPIs (UA) - LemBS
PDF
Oleksandr Ivakhnenko: LinkedIn Marketing і Content Marketing: розширений підх...
PDF
Maksym Vyshnivetskyi: PMO Quality Management (UA)
PDF
Oleksandr Ivakhnenko: Вступ до генерації лідів для ІТ-аутсорсингу (UA)
PDF
Oleksandr Osypenko: Поради щодо іспиту та закриття курсу (UA)
PDF
Oleksandr Osypenko: Пробний іспит + аналіз (UA)
PDF
Oleksandr Osypenko: Agile / Hybrid Delivery (UA)
PDF
Oleksandr Osypenko: Стейкхолдери та їх вплив (UA)
PDF
Rostyslav Chayka: Prompt Engineering для проєктного менеджменту (Advanced) (UA)
PPTX
Dmytro Liesov: PMO Tools and Technologies (UA)
PDF
Rostyslav Chayka: Управління командою за допомогою AI (UA)
PDF
Oleksandr Osypenko: Tailoring + Change Management (UA)
PDF
Maksym Vyshnivetskyi: Управління закупівлями (UA)
PDF
Oleksandr Osypenko: Управління ризиками (UA)
PPTX
Dmytro Zubkov: PMO Resource Management (UA)
PPTX
Rostyslav Chayka: Комунікація за допомогою AI (UA)
PDF
Ihor Pavlenko: Комунікація за допомогою AI (UA)
PDF
Maksym Vyshnivetskyi: Управління якістю (UA)
PDF
Ihor Pavlenko: Робота зі стейкхолдерами за допомогою AI (UA)
PDF
Maksym Vyshnivetskyi: Управління вартістю (Cost) (UA)
Maksym Vyshnivetskyi: PMO KPIs (UA) - LemBS
Oleksandr Ivakhnenko: LinkedIn Marketing і Content Marketing: розширений підх...
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Oleksandr Ivakhnenko: Вступ до генерації лідів для ІТ-аутсорсингу (UA)
Oleksandr Osypenko: Поради щодо іспиту та закриття курсу (UA)
Oleksandr Osypenko: Пробний іспит + аналіз (UA)
Oleksandr Osypenko: Agile / Hybrid Delivery (UA)
Oleksandr Osypenko: Стейкхолдери та їх вплив (UA)
Rostyslav Chayka: Prompt Engineering для проєктного менеджменту (Advanced) (UA)
Dmytro Liesov: PMO Tools and Technologies (UA)
Rostyslav Chayka: Управління командою за допомогою AI (UA)
Oleksandr Osypenko: Tailoring + Change Management (UA)
Maksym Vyshnivetskyi: Управління закупівлями (UA)
Oleksandr Osypenko: Управління ризиками (UA)
Dmytro Zubkov: PMO Resource Management (UA)
Rostyslav Chayka: Комунікація за допомогою AI (UA)
Ihor Pavlenko: Комунікація за допомогою AI (UA)
Maksym Vyshnivetskyi: Управління якістю (UA)
Ihor Pavlenko: Робота зі стейкхолдерами за допомогою AI (UA)
Maksym Vyshnivetskyi: Управління вартістю (Cost) (UA)

Recently uploaded (20)

PDF
Daniels 2024 Inclusive, Sustainable Development
PDF
Building a Smart Pet Ecosystem: A Full Introduction to Zhejiang Beijing Techn...
PPTX
Principles of Marketing, Industrial, Consumers,
PPTX
Slide gioi thieu VietinBank Quy 2 - 2025
PDF
IFRS Notes in your pocket for study all the time
PDF
Deliverable file - Regulatory guideline analysis.pdf
PDF
THE COMPLETE GUIDE TO BUILDING PASSIVE INCOME ONLINE
PDF
Solaris Resources Presentation - Corporate August 2025.pdf
PDF
Solara Labs: Empowering Health through Innovative Nutraceutical Solutions
PDF
Charisse Litchman: A Maverick Making Neurological Care More Accessible
PPTX
3. HISTORICAL PERSPECTIVE UNIIT 3^..pptx
PDF
Ôn tập tiếng anh trong kinh doanh nâng cao
PDF
1911 Gold Corporate Presentation Aug 2025.pdf
PPTX
Board-Reporting-Package-by-Umbrex-5-23-23.pptx
PDF
Blood Collected straight from the donor into a blood bag and mixed with an an...
PDF
Technical Architecture - Chainsys dataZap
PPTX
sales presentation، Training Overview.pptx
PDF
Booking.com The Global AI Sentiment Report 2025
PDF
How to Get Business Funding for Small Business Fast
PPTX
2025 Product Deck V1.0.pptxCATALOGTCLCIA
Daniels 2024 Inclusive, Sustainable Development
Building a Smart Pet Ecosystem: A Full Introduction to Zhejiang Beijing Techn...
Principles of Marketing, Industrial, Consumers,
Slide gioi thieu VietinBank Quy 2 - 2025
IFRS Notes in your pocket for study all the time
Deliverable file - Regulatory guideline analysis.pdf
THE COMPLETE GUIDE TO BUILDING PASSIVE INCOME ONLINE
Solaris Resources Presentation - Corporate August 2025.pdf
Solara Labs: Empowering Health through Innovative Nutraceutical Solutions
Charisse Litchman: A Maverick Making Neurological Care More Accessible
3. HISTORICAL PERSPECTIVE UNIIT 3^..pptx
Ôn tập tiếng anh trong kinh doanh nâng cao
1911 Gold Corporate Presentation Aug 2025.pdf
Board-Reporting-Package-by-Umbrex-5-23-23.pptx
Blood Collected straight from the donor into a blood bag and mixed with an an...
Technical Architecture - Chainsys dataZap
sales presentation، Training Overview.pptx
Booking.com The Global AI Sentiment Report 2025
How to Get Business Funding for Small Business Fast
2025 Product Deck V1.0.pptxCATALOGTCLCIA

Lviv MD Day 2015 Павло Захаров "Reactive cocoa: paradigm shift"

  • 1. Pavlo Zakharov Reactive Cocoa: Paradigm shift. - What is Reactive functional Paradigm? - Why consider using ReactiveCocoa? - RAC Signal.Unifying all of Cocoa’s common patterns. - RAC and concurrency. - Implementing MVVM design pattern on iOS with RAC.
  • 2. What is Reactive Functional Programming?
  • 3. Functional reactive programming (FRP) is a programming paradigm for reactive programming (asynchronous dataflow programming) using the building blocks of functional programming (e.g. map, reduce, filter). FRP has been used for programming graphical user interfaces (GUIs), robotics, and music, aiming to simplify these problems by explicitly modelling time. (c) Wikipedia
  • 4. Reactive+Functional: ❖ Static/Dynamic data flow.(Programming based on Events) ❖ (Functional Blocks) Functions passed as arguments to functions.
  • 5. Cocoa Events ❖ Delegation ❖ KVO ❖ Target - Action ❖ Callback Blocks ❖ NSNotifications }RacSignal
  • 6. RACSignal ❖ Next ❖ Error ❖ Completed Ray Signal emits: [self.searchText.rac_textSignal subscribeNext:^(id x) { NSLog(@"Next ocured"); }error:^(NSError *error) { NSLog(@"Error ocured"); }completed:^{ NSLog(@"Completed"); }]; Signal can have one or multiple subscribers
  • 8. Reactive Operations ❖ Map ❖ Throttle ❖ Skip ❖ Filter ❖ DeliverOn ❖ more…
  • 9. Operations don’t care about signal source.
  • 10. Map ❖ Transforms the value of the event(As transformed value as input signal can be literally anything) RACSignal *mySignal = [textSignal map:^id(NSString *text) { return @(text.length>3); }]; [mySignal subscribeNext:^(NSNumber* x) { if ([x boolValue]) { //... } }];
  • 11. Combine ❖ Combines two RAC Events(Next Emits when one of combined events occurs). RACSignal *switch1Signal = … RACSignal *switch2Signal = … RACSignal *both = [RACSignal combineLatest:@[switch1Signal,switch2Signal] reduce:^id(NSNumber *switch1, NSNumber *switch2){ return @([switch1 boolValue] && [switch2 boolValue]); }]; [both subscribeNext:^(id x) { if([x boolValue]){ NSLog(@"Both"); } }];
  • 12. Filter ❖ Event will be emitted only if the condition is satisfied. [[self.usernameTextField.rac_textSignal filter:^BOOL(id value) { return (((NSString*)value).length>3); }]subscribeNext:^(id x) { NSLog(@"do stuff"); }];
  • 13. Throttle ❖ If event occurrence once more within time interval specified event wouldn’t be emitted.(Extremely useful for locking buttons to prevent speed clicking) [[[self.usernameTextField.rac_textSignal filter:^BOOL(id value) { return (((NSString*)value).length>3); }]throttle:0.5]subscribeNext:^(id x) { NSLog(@"do stuff"); }];
  • 14. Deliver On ❖ The block will be executed on thread specified (For example for UI stuff on main thread) [[[self.usernameTextField.rac_textSignal filter:^BOOL(id value) { return (((NSString*)value).length>3); }] deliverOn:[RACScheduler mainThreadScheduler]]subscribeNext:^(id x) { NSLog(@"do UI stuff"); }];
  • 15. How to mix reactive code with non-reactive?
  • 16. Option one: doNext block ❖ doNext Block will be executed before subscriberBlock will be called.This is the good place for reactive code. [[[self.signInButton rac_signalForControlEvents:UIControlEventTouchUpInside] doNext:^(id x) { //put your non-reactive code here }] subscribeNext:^(NSNumber *signedIn) { //do stuff }];}
  • 17. Wrap non-reactive code to reactive ❖ Method will create signal which can emit next/error/completed event based on your non- reactive conditions. -(RACSignal *)switchSignal{ return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { (self.switch1.isOn)?[subscriber sendNext:@(YES)] : [subscriber sendNext:@(NO)]; return nil; }]; } //. //. //. [[self switchSignal]subscribeNext:^(id x) { //doStuff }];
  • 18. Bind Signal to UIEvent ❖ Every time touchUpInside event occurs next event will be emitted; RACSignal *mySignal = [self.getButton rac_signalForControlEvents:UIControlEventTouchUpInside]
  • 19. Avoid Retain cycles ❖ Accessing self in block can cause retain cycle and memory leak.Use __weak self to prevent it. @weakify(self); [self.searchText.rac_textSignal subscribeNext:^(id x) { @strongify(self); // self.smth = smth }error:^(NSError *error) { @strongify(self); // self.smthElse = smth }completed:^{ @strongify(self); // self.smthReallyDifferent = smth }];
  • 21. ViewModel ❖ ViewModel which is a special type of model that represents the UI state of the application ViewView ViewModelViewModel ModelModel ViewView ViewModelViewModel ModelModelControllerController
  • 22. Binding ❖ Binds textField.text to the property in ViewModel. Every time property changes text will change as well. (WPF implementation is shown on the right) RAC(self.searchText,text) = self.myString;  <TextBlock TextContent=”{Binding Path=Description}” /> ~
  • 23. Why should i use RAC? ❖ Unified interface for all Cocoa events. ❖ Less code in comparison with non-reactive code. ❖ No massive ViewControllers with complicated relationships. ❖ Easy work with concurrency. ❖ No complicated “States” needed.
  • 24. Some Disadvantages ❖ Debug Hell. ❖ Little overhead ❖ Weird syntax.(But you will get used to it)
  • 25. Resources ❖ https://github.com/ReactiveCocoa/ReactiveCocoa ❖ http://www.raywenderlich.com ❖ http://blog.scottlogic.com/2014/07/24/mvvm-reactivecoc ❖ https://www.youtube.com/watch?v=DgdISd1Qc48 ❖ https://www.youtube.com/watch?v=fWV7xyN5CR8 ❖ https://github.com/ZakharovPaul/RacDemo.git