Upload
johnlvidal
View
124
Download
2
Embed Size (px)
Citation preview
Who am I?
• C# Developer
• 6 years working with C#
• 2 years using Rx
• http://ca.linkedin.com/pub/john-vidal/73/33b/812/
• http://stackoverflow.com/users/1128106/j-lennon
Aim of this talk
• Reactive Extensions
• Reactive Programming
• Reactive Technology
• Reactive Scenarios
What’s Reactive Extensions
• Library
Used to:
• Real-time data
• Push notifications
• Asynchronous requests
• Event processing
Main goals:
• Unique interface
• Compose operations
• Good code
• Created by Microsoft in 2009
• Initially called LINQ To Events
• Turned into an Open Source Project 2 years ago
History of Rx
Rx Flavors
• RxPHP
• Rx.Py (for Python)
• Rx.Rb (for Ruby)
• RxJs (for JavaScript)
• RxCpp (for C++)
• Rx-Haskeel
• Rx-Pearl
• Rx-Java
• Mono
Reactive - What’s the Point?
• By Microsoft:
Reactive Extensions is for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators.
• By Wikipedia:
Reactive Programming is a programming paradigm oriented around data flows and the propagation of change.
• By Reactive Manifesto:
Reactive Systems are Responsive, Elastic, Resilient, Message Driven.
Specific Scenarios
• Real-time data• TCP/IP directly (duplex communication)
• Real-time web technologies (e.g. Polling, Server Side Events, WebSocket)
• Serial data (e.g. USB/RS 232)
*In .NET: WCF using duplex binding or SignalR.
• Push notifications• Mobile devices (e.g. IOS/Android/WP)
• Web browser extensions (e.g. Chrome/Firefox)
• Windows 8 apps
Common Scenarios
• Propagation of Change• If you need tell somebody that something happens. For example:
- Any kind of event-based, asynchronous-based, subscription-based, notification-based mechanism.
- Especially in combination or composition of more than one them
Common Apps
• Chat
• Stock Ticker
• Social Media
• Monitoring
• Games
• Dashboard
• Manufacturing
• Industrial Systems
• Event-driven Marketing
• Internet of Things
• Gestures (Kinect, Leap Motion)
References / To know more
Links:
• http://channel9.msdn.com/Tags/reactive+extensions
• http://www.introtorx.com/
• http://xgrommx.github.io/rx-book/
• http://reactconf.com/
• http://www.reactivemanifesto.org/
• http://www.infoq.com/reactive-extensions/
• http://blogs.msdn.com/b/rxteam/
People:
• Bart de Smet (Microsoft)
• Erik Meijer (Microsoft)
• Lee Campbell (IntroToRx)
• Jafar Hussain (Netflix)
• Jonathan Worthington
• James World
• Jim Wooley
• Dave Sexton
• Phil Haack
Bridges with Rx
• Event-based operations• Any kind of Binding (e.g. using patterns such as: MVVM, MVVMC, MVPVM)
*In .NET: event keyword (e.g. EventHandler delegate such as PropertyChangedEventHandler for INotifyPropertyChanged)
• Async-based operations• Callback / Promise / Future / Task
*In .NET: APM (IAsyncResult), EAP (EventNameCompleted += Handler), TAP (Task.Run(DoSomething)).
• Time-based operations• Scheduling / Timeout
Especially in combination or composition of one or more scenarios.
Who are using Reactive Extensions?
• 300.000+ downloads on Nuget.org (.NET Version)
• Netflix
• Microsoft Bing/Cortana/Azure
• GitHub Windows Client
• Hundreds of repositories in GitHub
• Dozens supporting http://reactivemanifesto.org with ribbons
The Major Interfaces
public interface IObservable<out T>
{
IDisposable Subscribe(IObserver<T> observer);
}
public interface IObserver<in T>
{
void OnCompleted(); // Notifies the observer that the source has finished sending messages.
void OnError(Exception error); // Notifies the observer about any exception or error.
void OnNext(T value); // Pushes the next data value from the source to the observer.
}
Reasons to use Rx
1. Avoid callback hell
2. Common interface to use in the code
3. Taming side-effects
Complexity
• Enumerable • 51 Operators
• EnumerableEx from Ix (Interactive Extensions)• 31 Operators
• Observable• 131 Operators