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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Vladimir Burdukov
February 24, 2014
Programming
130
1
Share
λ is coming to Obj-C – ReactiveCocoa
Vladimir Burdukov
February 24, 2014
More Decks by Vladimir Burdukov
See All by Vladimir Burdukov
Alice in robovacuum land
chipp
0
67
It’s time to migrate from RxSwift to Combine. Long story short
chipp
0
96
Decodable vs real-world JSON
chipp
0
86
`fastlane beta` 2 или почему я стал пить больше кофе
chipp
0
640
`fastlane beta` или почему я стал пить больше кофе
chipp
0
150
Архитектурные излишества в iOS приложениях Superjob
chipp
0
210
λ is coming to Obj-C – ReactiveCocoa
chipp
0
410
Build bots
chipp
0
130
Other Decks in Programming
See All in Programming
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.2k
Swiftのレキシカルスコープ管理
kntkymt
0
200
分析エージェント精度向上における データアナリストの役割
oura_shoya
0
130
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
2.9k
LLM Plugin for Node-REDの利用方法と開発について
404background
0
130
Skillは並べた。動かなかった。契約で繋いだ。— 65個のSkillから、自走する開発サイクルへ
junholee
0
770
Moments When Things Go Wrong
aurimas
3
120
さぁV100、メモリをお食べ・・・
nilpe
0
100
1人1案件のプロダクトエンジニア時代に、"プロセス監督"としてチャレンジしたこと
non0113
0
340
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
1
380
CSC307 Lecture 17
javiergs
PRO
0
260
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
230
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Making Projects Easy
brettharned
120
6.6k
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Practical Orchestrator
shlominoach
191
11k
Designing for humans not robots
tammielis
254
26k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
A designer walks into a library…
pauljervisheath
211
24k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
140
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
920
Raft: Consensus for Rubyists
vanstee
141
7.5k
The Pragmatic Product Professional
lauravandoore
37
7.3k
Transcript
λ is coming to Obj-C: ReactiveCocoa Vladimir @chippcheg Burdukov
Imperative
Declarative
Functional programming λ-calculus
Functional programming
Pure function • result doesn’t depend on any state •
function doesn’t change any external state.
Pure function def sqr(x: Int): Int = x * x
//> sqr: (x: Int)Int sqr(2) /> res4: Int = 4 def add1(x: Int): Int = x + 1 //> add1: (x: Int)Int add1(4) //> res3: Int = 5 add1(add1(4)) //> res4: Int = 6
Higher-order functions
Higher-order functions def sqr(x: Int): Int = x * x
def sumF(x: Int, y: Int, f: Int => Int) = f(x) + f(y) sumF(3, 4, sqr) //> res5: Int = 25
Higher-order functions def sqr(x: Int): Int = x * x
def sumF(x: Int, y: Int, f: Int => Int) = f(x) + f(y) sumF(3, 4, sqr) //> res5: Int = 25 sumF(-9, 16, abs) //> res6: Int = 25
Tail recursion
Tail recursion Lists Head Tail
Tail recursion Lists val foo: List[Int] = 1 to 5
toList //> foo : List[Int] = List(1, 2, 3, 4, 5) val foohead = foo.head //> foohead : Int = 1 val footail = foo.tail //> footail : List[Int] = List(2, 3, 4, 5)
Tail recursion def sumList(xs: List[Int]): Int = if (xs ==
Nil) return 0 else return xs.head + sumList(xs.tail) // > sumList: (xs: List[Int])Int ! sumList(foo) //> res3: Int = 15
Composition
Composition def f(a: String): String = "f(" + a +
")" f("5") //> res11: String = f(5) def g(a: String): String = "g(" + a + “)" g("5") //> res12: String = g(5) f(g("5")) //> res13: String = f(g(5)) def fg = f _ compose g _ //> fg: => String => String fg("5") //> res14: String = f(g(5))
Functional programming References •https://www.coursera.org/course/progfun
Reactive Programming
Reactive Programming 5 10 =SUM(A1;B1) A1 B1 C1
Functional Reactive Programming
ReactiveCocoa Next step of Objective-C evolution https://github.com/ReactiveCocoa/ReactiveCocoa/
Introduction https://github.com/ReactiveCocoa/ReactiveCocoa/blob/master/Documentation/
Introduction https://github.com/ReactiveCocoa/ReactiveCocoa/blob/master/Documentation/ pod
RACSequense RACSignal
RACSignal
RACSignal UISwitch *settingSwitch = [[UISwitch alloc] init]; RACSignal *switchSignal =
[settingSwitch rac_signalForControlEvents:UIControlEventValueChanged]; [switchSignal subscribeNext:^(UISwitch *x) { NSLog(@"SWITCH %@", x.on); }]; //SWITCH 0 //SWITCH 1 //SWITCH 0
RACSignal signal subscribeNext:
RACSignal Composition [[[self.field rac_textSignal] filter:^BOOL(NSString *value) { return value.length >=
8; }] subscribeNext:^(id x) { NSLog(@"%@", x); }];
RACSignal Combining signal signal combine reduce YES/NO NSString NSString
RACSignal Combining RAC(self.createButton, enabled) = [RACSignal combineLatest:@[self.loginField.rac_textSignal, self.passwordField.rac_textSignal] reduce:^id(NSString *username,
NSString *password) { return @(username.length > 0 && password.length > 0); }];
RACSequence
Binding RAC(self.avatarImageView, image) = RACObserve(self.viewModel, userAvatar);
ReactiveCocoa UI extensions • UIActionSheet / UIAlertView • UIButton •
UITableViewCell • UIControl (rac_signalForControlEvents:) • UIGestureRecognizer • UITextField
UIAlertView Signal UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Something goes
wrong" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:@"Retry", nil]; ! [[alertView rac_buttonClickedSignal] subscribeNext:^(NSNumber *buttonNumber) { NSLog(@"alert button: %@", [alertView buttonTitleAtIndex:buttonNumber.intValue]); }];
UIButton Command RACCommand *loginCommand = [[RACCommand alloc] initWithEnabled:[RACSignal combineLatest:@[loginField.rac_textSignal, passwordField.rac_textSignal]
reduce:^id(NSString *username, NSString *password) { return @(username.length > 0 && password.length > 0); }] signalBlock:^RACSignal *(id input) { return [[JMHSync shared] loginUser:self.loginField.text withPassword:self.passwordField.text]; }]; ! self.createButton.rac_command = loginCommand;
UITextField Signal [self.loginField.rac_textSignal subscribeNext:^(NSString *x) { NSLog(@"you entered %@", x);
}];
Conclusion
Questions
Thank you!