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
February 24, 2014
Programming
1
120
λ is coming to Obj-C – ReactiveCocoa
Vladimir Burdukov
February 24, 2014
Tweet
Share
More Decks by Vladimir Burdukov
See All by Vladimir Burdukov
Alice in robovacuum land
chipp
0
56
It’s time to migrate from RxSwift to Combine. Long story short
chipp
0
79
Decodable vs real-world JSON
chipp
0
58
`fastlane beta` 2 или почему я стал пить больше кофе
chipp
0
550
`fastlane beta` или почему я стал пить больше кофе
chipp
0
130
Архитектурные излишества в iOS приложениях Superjob
chipp
0
180
λ is coming to Obj-C – ReactiveCocoa
chipp
0
370
Build bots
chipp
0
120
Other Decks in Programming
See All in Programming
大LLM時代にこの先生きのこるには-ITエンジニア編
fumiyakume
7
3.1k
Sharing features among Android applications: experience feedback
jbvincey
0
110
Empowering Developers with HTML-Aware ERB Tooling @ RubyKaigi 2025, Matsuyama, Ehime
marcoroth
2
740
Cursor/Devin全社導入の理想と現実
saitoryc
15
9.9k
Vibe Coding の話をしよう
schroneko
10
2.6k
Vibe Codingをせずに Clineを使っている
watany
17
6.3k
RubyKaigi Dev Meeting 2025
tenderlove
1
200
Module Boundaries and Architecture with Forensic Analysis @NxSummit Amsterdam 2025
manfredsteyer
PRO
0
100
サービスクラスのありがたみを発見したときの思い出 #phpcon_odawara
77web
4
680
Kamal 2 – Get Out of the Cloud
aleksandrov
1
190
Bedrock×MCPで社内ブログ執筆文化を育てたい!
har1101
6
1k
AHC045_解説
shun_pi
0
550
Featured
See All Featured
Done Done
chrislema
183
16k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
104
19k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Thoughts on Productivity
jonyablonski
69
4.6k
RailsConf 2023
tenderlove
30
1.1k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.2k
Into the Great Unknown - MozCon
thekraken
37
1.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.2k
Fireside Chat
paigeccino
37
3.4k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
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!