Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
λ is coming to Obj-C – ReactiveCocoa
Search
Vladimir Burdukov
December 07, 2013
Programming
410
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
λ is coming to Obj-C – ReactiveCocoa
Vladimir Burdukov
December 07, 2013
More Decks by Vladimir Burdukov
See All by Vladimir Burdukov
Alice in robovacuum land
chipp
0
68
It’s time to migrate from RxSwift to Combine. Long story short
chipp
0
97
Decodable vs real-world JSON
chipp
0
87
`fastlane beta` 2 или почему я стал пить больше кофе
chipp
0
640
`fastlane beta` или почему я стал пить больше кофе
chipp
0
150
Архитектурные излишества в iOS приложениях Superjob
chipp
0
220
λ is coming to Obj-C – ReactiveCocoa
chipp
1
130
Build bots
chipp
0
130
Other Decks in Programming
See All in Programming
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
260
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
240
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.7k
スマートグラスで並列バイブコーディング
hyshu
0
150
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
170
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
170
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
250
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
250
Webフレームワークの ベンチマークについて
yusukebe
0
170
Featured
See All Featured
The browser strikes back
jonoalderson
0
1.3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
620
Documentation Writing (for coders)
carmenintech
77
5.4k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
How to make the Groovebox
asonas
2
2.2k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
460
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
580
Evolving SEO for Evolving Search Engines
ryanjones
0
220
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Transcript
λ is coming to Obj-C: ReactiveCocoa Vladimir @chippcheg Burdukov Lead
Hipster Developer at HiQo Solutions
State
Let’s enumerate NSMutableArray
Functional programming
Stateless
Stateless Composition
Stateless Composition Concurrency https://class.coursera.org/progfun-003/class http://twitter.github.io/scala_school/index.html
Composition
Composition package cocoaheads ! object cocoaheads { def fib(n: Int):
List[Int] = { def tail(n: Int, p: Int, m: Int): List[Int] = if (n == 1) List(p) else p :: tail(n - 1, m, p + m) tail(n, 1, 1) } //> fib: (n: Int)List[Int] fib(4) //> res0: List[Int] = List(1, 1, 2, 3) fib(4).zip(fib(4).map((x: Int) => x * x)) //> res1: List[(Int, Int)] = List((1,1), (1,1), (2,4), (3,9)) fib(4).foldLeft(0)((m: Int, n: Int) => m + n) //> res2: Int = 7 } http://bcomposes.wordpress.com/2011/08/20/fun-with- function-composition-in-scala/
Functional Programming
Functional Reactive Programming
Functional Reactive Programming
ReactiveCocoa Next step of Objective-C evolution https://github.com/ReactiveCocoa/ReactiveCocoa/
Introduction https://github.com/ReactiveCocoa/ReactiveCocoa/blob/master/ Documentation/
RACStream RACSequense RACSignal
RACSignal
RACSignal RACSignal *signal = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { if
(value) { [subscriber sendNext:value]; [subscriber sendCompleted]; } else { [subscriber sendError:error]; } return nil; }];
RACSignal [signal subscribeNext:^(id x) { NSLog(@"SIGNAL NEW VALUE: %@", x);
} error:^(NSError *error) { NSLog(@"SIGNAL ERROR: %@", error); } completed:^{ NSLog(@"SIGNAL COMPLETED"); }]; RACSignal *signal = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { if (value) { [subscriber sendNext:value]; [subscriber sendCompleted]; } else { [subscriber sendError:error]; } return nil; }];
RACSignal *loginEditingSignal = [[self.loginField rac_signalForControlEvents:UIControlEventEditingChanged] map:^id(UITextField *x) { return @(x.isEditing);
}]; ! RACSignal *passwordEditingSignal = [[self.passwordField rac_signalForControlEvents:UIControlEventEditingChanged] map:^id(UITextField *x) { return @(x.isEditing); }]; RAC(self.tapGestureRecognizer, enabled) = [RACSignal combineLatest:@[loginEditingSignal, passwordEditingSignal] reduce:^id(NSNumber *loginIsEditing, NSNumber *passwordIsEditing){ return @([loginIsEditing boolValue] || [passwordIsEditing boolValue]); }]; RACSignal Combining
RACSequence
RACSequence RACSequence *fib(int n) { return fibTail(n, 1, 1); }
! RACSequence *fibTail(int n, int p, int m) { return [RACSequence sequenceWithHeadBlock:^NSNumber *{ return @(p); } tailBlock:^RACSequence *{ if (n == 1) { return [RACSequence empty]; } else { return fibTail(n - 1, m, p + m); } }]; } ! NSLog(@"%@", fib(4).array); // [1, 1, 2, 3] ! NSLog(@"%@", [fib(4) zipWith:[fib(4) map:^NSNumber *(NSNumber *value) { return @([value integerValue] * [value integerValue]); }]].array); // [(1, 1), (1, 1), (2, 4), (3, 9)] ! NSLog(@"%@", [fib(4) foldLeftWithStart:@0 reduce:^NSNumber *(NSNumber *accumulator, NSNumber *value) { return @(accumulator.integerValue + value.integerValue); }]); // 7
RACDisposable
RACScheduler
Binding RAC(avatarImageView, image) = RACObserve(self.viewModel, userAvatar);
ReactiveCocoa UI extensions • UIActionSheet / UIAlertView • UIButton •
UITableViewCell • UIControl (rac_signalForControlEvents:) • UIGestureRecognizer • UITextField
Conclusion
Questions