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
110
Decodable vs real-world JSON
chipp
0
91
`fastlane beta` 2 или почему я стал пить больше кофе
chipp
0
650
`fastlane beta` или почему я стал пить больше кофе
chipp
0
150
Архитектурные излишества в iOS приложениях Superjob
chipp
0
220
λ is coming to Obj-C – ReactiveCocoa
chipp
1
140
Build bots
chipp
0
130
Other Decks in Programming
See All in Programming
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
210
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
220
What's New in Android 2026
veronikapj
0
240
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
300
Foundation Models frameworkで画像分析
ryodeveloper
1
440
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
4
1.8k
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
190
今さら聞けない .NET CLI
htkym
0
170
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
270
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
180
AIが無かった頃の素敵な出会いの話
codmoninc
1
360
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
380
Featured
See All Featured
Done Done
chrislema
186
16k
Designing Experiences People Love
moore
143
24k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
420
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
200
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.3k
Writing Fast Ruby
sferik
630
63k
Facilitating Awesome Meetings
lara
57
7.1k
Automating Front-end Workflow
addyosmani
1370
210k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
520
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
650
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
350
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