В докладе расскарывается тема использования функционально-реактивного подхода для разработки iOS- и Mac-приложений, его достоинства и недостатки. Также рассказано об использовании паттерна Model-View-View Model для улучшения архитектуры и повышения тестируемости GUI-кода.
2. REACTIVE COCOA
•
Objective-C framework for processing and composing streams
•
Unifies async Cocoa patterns: callbacks, delegates, KVO,
notifications
•
Very composable
•
Helps to minimize state
•
Inspired by Reactive Extensions for .NET
4. FUTURES
•
Future can either complete with a value or reject
with an error
•
JavaScript Promises/A+
•
There are some Objective-C implementations
•
RAC can into futures too
6. RACSignal
•
A stream of values
•
One can subscribe to new value, error or completion
•
Supports functional constructs: map, filter, flatMap, reduce
etc
•
Сold or hot
•
A monad
8. STREAMS
•
Powerful abstraction
•
Streams for futures is like iterables for scalar values
•
Umbrella concept for asynchronous Cocoa
patterns
•
You can even use signals as values. Yo dawg…
13. ISSUES
•
Steep learning curve
•
Runtime overhead
•
Tricky debugging: crazy call stacks, lots of asynchrony,
retain cycles
•
You’ll need to deal with imperative Cocoa API anyway
•
Losing last bits of type information
18. MVVM
•
MVVM knows nothing about a view
•
MVVM uses underlying layers (persistence, web
service clients, cache) to populate view data
•
You can even use it with ncurses
19. WHY MVVM?
•
Clear separation between view and presentation logiс
•
Reusability across different views and even platforms
•
Testability
•
View models are models
•
Persistence can be hidden behind view model
20. YOU ALREADY CLOSER TO
MVVM THAN YOU THINK
Big monolithic view controllers
!
External data sources, data converters & services
!
MVVM
24. RACCommand
•
Runs signal block on -execute: and subscribes to its result
•
Multicasts execution signals to consumers
•
Multicasts inner signal errors to consumers
•
Enabled/disabled state can be controlled by a bool signal
•
Exposes execution state (running/not running)
•
Can be bound to UI control
26. •
Make no assumptions about a view
•
Expose bindable properties or signals
•
Expose commands to consumers
•
Throttle/unsubscribe signals when view is
inactive