Presented at YOW! Connected 2015 (Melbourne) by Jeames Bone & Mark Corbyn:
"There are many great resources for getting started with Functional Reactive Programming and ReactiveCocoa, but what’s the next step? ReactiveCocoa is not just a nice wrapper for KVO, Signals can be used to model many common problems in Cocoa including managing the state of your UI, notifications and even business logic. Adopting ReactiveCocoa can make for more modular, self-documenting code — while still integrating easily with other APIs and your existing code. We would like to share with you some interesting, practical examples where we’ve used ReactiveCocoa to solve problems in our app. Our goal is to inspire you to consider how ReactiveCocoa can be applied in your own apps."
This is my talk on ReactiveCocoa at @cocoaheads_at in Vienna. I gave an introduction to reactive programming with RAC and an overview of signals and subscribers, and how they can be used to create useful patterns.
ReactiveCocoa is an elegant framework that radically changes the way we structure our applications and handle flows of data. However, it's beauty is somewhat marred by Objective-C!
In this talk Colin will cover the basics of ReactiveCocoa and the principles of Functional Reactive Programming. Through simple practical examples he will show how ReactiveCocoa and Swift form a beautiful partnership.
Introduction to reactive programming & ReactiveCocoaFlorent Pillet
A short introduction to the concepts of functional reactive programming, and their implementation in ReactiveCocoa, a framework for iOS and OS X developers.
This speech was given at CocoaHeads Paris, October 9th 2014
En vieux bourlingueur du langage Swift, Grégoire Lhotellier viendra nous présenter les séquences et les collections du nouveau langage d’Apple. Il nous briefera sur l’essentiel de ce qu’il faut en savoir et ce qu’elles changent par rapport à leurs équivalent Objective-C.
This is my talk on ReactiveCocoa at @cocoaheads_at in Vienna. I gave an introduction to reactive programming with RAC and an overview of signals and subscribers, and how they can be used to create useful patterns.
ReactiveCocoa is an elegant framework that radically changes the way we structure our applications and handle flows of data. However, it's beauty is somewhat marred by Objective-C!
In this talk Colin will cover the basics of ReactiveCocoa and the principles of Functional Reactive Programming. Through simple practical examples he will show how ReactiveCocoa and Swift form a beautiful partnership.
Introduction to reactive programming & ReactiveCocoaFlorent Pillet
A short introduction to the concepts of functional reactive programming, and their implementation in ReactiveCocoa, a framework for iOS and OS X developers.
This speech was given at CocoaHeads Paris, October 9th 2014
En vieux bourlingueur du langage Swift, Grégoire Lhotellier viendra nous présenter les séquences et les collections du nouveau langage d’Apple. Il nous briefera sur l’essentiel de ce qu’il faut en savoir et ce qu’elles changent par rapport à leurs équivalent Objective-C.
As presented at DevDuck #6 - JavaScript meetup for developers (www.devduck.pl)
----
Looking for a company to build your app? - Check us out at www.brainhub.eu
This talk was given at JSSummit 2013. Entitled "Avoiding Callback Hell with Async.js", my talk focused on common pitfalls with asynchronous functions and callbacks in JavaScript, and using the async.js library and its advanced control flows to create cleaner, more manageable code.
An exploration into RxJava on Android for the experienced, yet uninitiated software engineer. This presentation explores Declarative vs Imperative programming paradigms and expands the discussion into Functional Reactive Programming. It explains the benefits of the observer contract, high-order functions, and schedulers available in RxJava. It also explains the purpose of the Android integration libraries: RxAndroid, RxLifecycle, and RxBindings.
The fundamentals and advance application of Node will be covered. We will explore the design choices that make Node.js unique, how this changes the way applications are built and how systems of applications work most effectively in this model. You will learn how to create modular code that’s robust, expressive and clear. Understand when to use callbacks, event emitters and streams.
As presented at DevDuck #6 - JavaScript meetup for developers (www.devduck.pl)
----
Looking for a company to build your app? - Check us out at www.brainhub.eu
This talk was given at JSSummit 2013. Entitled "Avoiding Callback Hell with Async.js", my talk focused on common pitfalls with asynchronous functions and callbacks in JavaScript, and using the async.js library and its advanced control flows to create cleaner, more manageable code.
An exploration into RxJava on Android for the experienced, yet uninitiated software engineer. This presentation explores Declarative vs Imperative programming paradigms and expands the discussion into Functional Reactive Programming. It explains the benefits of the observer contract, high-order functions, and schedulers available in RxJava. It also explains the purpose of the Android integration libraries: RxAndroid, RxLifecycle, and RxBindings.
The fundamentals and advance application of Node will be covered. We will explore the design choices that make Node.js unique, how this changes the way applications are built and how systems of applications work most effectively in this model. You will learn how to create modular code that’s robust, expressive and clear. Understand when to use callbacks, event emitters and streams.
Angular 16 is the biggest release since the initial rollout of Angular, and it changes everything: Bye bye zones, change-detection, life-cycle, children-selectors, Rx and what not.
Recorded webinar based on these slides given by Yaron Biton, Misterbit Coding-Academy’s CTO, can be found at: https://www.youtube.com/watch?v=92K1fgPbku8
Coding-Academy offers advanced web-techs training and software development services: Top-rated Full-stack courses for Angular, React, Vue, Node, Modern architectures, etc. | Available top-notch on-demand-coders trough Misterbit technological solutions | Coding-Academy Bootcamp: Hundreds of employed full-stack developers every year | Anything web, end to end projects | Tech companies and startups | Consulting to management and dev teams | Workshops for managers and leaders.
In this talk, I'm presenting an alternative approach to thinking about UI and navigation on iOS - one that is declarative and that I find easy to reason about in a big application. I did live coding and the link is on the last slide. Enjoy!
A Series of Fortunate Events - PHP Benelux Conference 2015Matthias Noback
What is an event really? How can you best describe an event in your code? What types of events are there, and how do you decide whether or not to implement something as an event?
In this talk we start with a straightforward command-only piece of code. We extract events from it and start moving the event handling code out, trying different design patterns on the way. First we try Observer. Then we introduce event data, event handlers and a Mediator between our code and the event handlers. Finally we pick a well-known event dispatcher implementation (the Symfony EventDispatcher) and see how it uses the Chain of Responsibility design pattern to control the entire flow of a web application request.
In the end I will answer some burning questions like: is it safe to use events all over the place and rely on event handlers to do some really important stuff? How do I overcome the indirection in my event-driven code? And how can I quickly find out what happens where?
From object oriented to functional domain modelingCodemotion
"From object oriented to functional domain modeling" by Mario Fusco
Malgrado l'introduzione delle lambda, la gran parte degli sviluppatori Java non è ancora abituata agli idiomi della programmazione funzionale e quindi non è pronta a sfruttare a pieno le potenzialità di Java 8. In particolare non è ancora comune vedere dati e funzioni usate insieme quando si modella un dominio di business. Lo scopo del talk è mostrare come alcuni principi di programmazione funzionale quali l'impiego di oggetti e strutture dati immutabili, l'uso di funzioni senza side-effect e il loro reuso mediante composizione, possono anche essere validi strumenti di domain modelling.
Pointer Events Working Group update / TPAC 2023 / Patrick H. LaukePatrick Lauke
Update about Pointer Events Level 3 work for the upcoming W3C Technical Plenary and Advisory Committee (TPAC) 2023 in Seville
https://www.youtube.com/watch?v=r0spZl1qaa0
https://w3c.github.io/pointerevents/
https://www.w3.org/TR/pointerevents/
https://www.w3.org/2023/09/TPAC/
https://patrickhlauke.github.io/touch/w3c_tpac2023_pewg/
Cross-posted from https://www.w3.org/2023/09/TPAC/group-updates.html#pointer-events
The base architecture of iOS is MVC (Model View Controller) which leads into known as Massive View Controller, where the View Controllers end up doing so many logic. It is easy to mix UI code and business logic together which is the wrong way to test the logic.
VIPER is one of a modern architecture made for this issue. It is based by Uncle Bob's Clean Architecture. It use the Separation of Concern principle which make the code cleaner and easy to maintenance.
ITT 2014 - Peter Steinberger - Architecting Modular CodebasesIstanbul Tech Talks
Everyone knows the pain of convoluted code as an application grows and feature after feature is being added. In this talk Peter lets you explore ideas how to grow your project in a healthy, maintainable way, how to manage dependencies, how to design code around testability, how to write plugins and even some practical solutions around the idea of aspect oriented programming. This is all based on a large-scale 150k lines project and Peter shows some production code as well.
Building Scalable Stateless Applications with RxJavaRick Warren
RxJava is a lightweight open-source library, originally from Netflix, that makes it easy to compose asynchronous data sources and operations. This presentation is a high-level intro to this library and how it can fit into your application.
15. Select the Right View Controller
RACSignal *authSignal = RACObserve(authStore, authenticated)
// Pick a view controller
RACSignal *viewControllerSignal =
[authenticatedSignal map:^(NSNumber *isAuthenticated) {
if (isAuthenticated.boolValue)
return [DashboardViewController new];
} else {
return [LoginViewController new];
}
}];
16. Select the Right View Controller
YES NO YES
Dash
board
Login
Dash
board
map { // BOOL to ViewController }
17. Displaying it on Screen
How do we get the value out?
We have to subscribe, like a callback.
- (void)viewDidLoad {
[super viewDidLoad];
// Whenever we get a new view controller, PUSH IT
[[viewControllerSignal deliverOnMainThread]
subscribeNext:^(UIViewController *viewController) {
[self showViewController:viewController sender:self];
}];
}
18. Ok, maybe that’s pushing it
Let’s make a custom view controller
container!
19. Switching to the latest view controller
@interface SwitchingController : UIViewController
- (instancetype)initWithViewControllers:(RACSignal *)viewControllers;
@property (nonatomic, readonly) UIViewController *currentViewController;
@end
Manages a signal of view controllers, always
displaying the most recent one
20. - (void)viewDidLoad {
[super viewDidLoad];
[[self.viewControllers deliverOnMainThread]
subscribeNext:^(UIViewController *viewController) {
[self transitionFrom:self.currentViewController to:viewController];
}];
}
Setting Up
When the view loads, subscribe to our signal
24. - (void)viewDidLoad {
[super viewDidLoad];
[[[self.viewControllers
throttle:0.5]
deliverOnMainThread]
subscribeNext:^(UIViewController *viewController) {
[self transitionFrom:self.currentViewController
to:viewController];
}];
}
Simple Throttling
Only take a new view controller if 0.5 seconds have
passed.
25. v2: Only throttle while animating
Keep track of when we’re animating
- (void)transitionFrom:(UIViewController *)fromViewController
to:(UIViewController *)toViewController {
// code
self.animating = YES;
[self transitionFromViewController:fromViewController
toViewController:toViewController
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:nil
completion:^(BOOL finished) {
// more code
self.animating = NO;
}];
}
26. v2: Only throttle while animating
Throttle only if we are animating
[[[self.viewControllers
throttle:0.5 valuesPassingTest:^(id _) {
return self.isAnimating;
}]
deliverOnMainThread]
subscribeNext:^(UIViewController *viewController) {
[self transitionFrom:self.currentViewController to:viewController];
}];
27. What have we learned?
• Signals can represent real world events (Logging in/out)
• We can transform them using operators like map
• We can control timing through operators like throttle
29. Hot Signals
• Events happen regardless of any observers.
• Stream of *events* happening in the world.
• e.g. UI interaction, notifications
30. Cold Signals
• Subscribing starts the stream of events.
• Stream of results caused by some side effects.
• e.g. network calls, database transactions
34. A New Friend!
Lift a selector into the reactive world
- (RACSignal *)rac_signalForSelector:(SEL)selector;
The returned signal will fire an event every time the
method is called.
35. Let’s Do It!
- (RACSignal *)notificationSignalForNotificationType:
(NotificationType)type {
return [[[self
rac_signalForSelector:@selector(application:didReceiveRemoteNotification:)]
map:^(RACTuple *arguments) {
return arguments.second;
}]
map:^(NSDictionary *userInfo) {
// Parse our user info dictionary into a model object
return [self parseNotification:userInfo];
}]
filter:^(Notification *notification)
notification.type = type;
}];
}
37. A Wild Local Notification Appears!
• We don't want to duplicate our current notification handling.
• Local and remote notifications should have the same effects.
39. Problem
• We only get notifications sent *after* we subscribe.
• We can't easily update app state or UI that is created after
the notification is sent.
41. Replay it
return [[[remoteNotificationInfo merge:localNotificationInfo]
map:^(NSDictionary *userInfo) {
// Parse our user info dictionary into a model object
return [self parseNotification:userInfo];
}]
filter:^(Notification *notification) {
return notification.type == type;
}]
replayLast];
return [[remoteNotificationInfo merge:localNotificationInfo]
map:^(NSDictionary *userInfo) {
// Parse our user info dictionary into a model object
return [self parseNotification:userInfo];
}]
filter:^(Notification *notification) {
return notification.type == type;
}];
42. What have we learned?
• Signals can model complex app behaviour like notifications
• We can combine signals in interesting ways
• Helpers like signalForSelector allow us to lift regular functions into signals
44. Describing an Algorithm with Functions
Example: Finding the best voucher to cover a
purchase
• If there are any vouchers with higher value than the purchase,
use the lowest valued of those
• Otherwise, use the highest valued voucher available
51. What have we learned?
• Functional code can be more readable
• It's easy to convert between imperative and functional
code using ReactiveCocoa
• Signals are lazy