Quick look in Reactive Extensions

Click here to load reader

  • date post

    17-Jul-2015
  • Category

    Technology

  • view

    101
  • download

    2

Embed Size (px)

Transcript of Quick look in Reactive Extensions

Reactive Extensions

Reactive ExtensionsCommon scenarios for the use of RxWho am I?C# Developer6 years working with C#2 years using Rx

[email protected]://ca.linkedin.com/pub/john-vidal/73/33b/812/http://stackoverflow.com/users/1128106/j-lennon

Aim of this talkReactive ExtensionsReactive ProgrammingReactive TechnologyReactive Scenarios

Whats Reactive ExtensionsLibrary

Used to: Real-time dataPush notificationsAsynchronous requestsEvent processing

Main goals:Unique interfaceCompose operationsGood code

Created by Microsoft in 2009Initially called LINQ To EventsTurned into an Open Source Project 2 years ago

History of RxRx Flavors RxPHPRx.Py (for Python)Rx.Rb (for Ruby)RxJs (for JavaScript)RxCpp (for C++)Rx-HaskeelRx-PearlRx-JavaMono Reactive - Whats 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 aprogramming paradigm oriented around data flows and the propagation of change.By Reactive Manifesto:Reactive Systems are Responsive, Elastic, Resilient, Message Driven.

Why Rx?

Specific ScenariosReal-time dataTCP/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 notificationsMobile devices (e.g. IOS/Android/WP)Web browser extensions (e.g. Chrome/Firefox)Windows 8 apps

Common ScenariosPropagation of ChangeIf 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 AppsChatStock TickerSocial MediaMonitoringGamesDashboardManufacturingIndustrial SystemsEvent-driven MarketingInternet of ThingsGestures (Kinect, Leap Motion)

References / To know moreLinks:

http://channel9.msdn.com/Tags/reactive+extensionshttp://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 WorthingtonJames WorldJim WooleyDave SextonPhil Haack Thank YouDemoThank YouBridges with RxEvent-based operationsAny 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 operationsCallback / Promise / Future / Task*In .NET: APM (IAsyncResult), EAP (EventNameCompleted += Handler), TAP (Task.Run(DoSomething)).Time-based operationsScheduling / Timeout

Especially in combination or composition of one or more scenarios.Who are using Reactive Extensions?300.000+ downloads on Nuget.org (.NET Version)

NetflixMicrosoft Bing/Cortana/AzureGitHub Windows Client

Hundreds of repositories in GitHubDozens supporting http://reactivemanifesto.org with ribbons

The Major Interfacespublic interface IObservable { IDisposable Subscribe(IObserver observer); }

public interface IObserver { 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 RxAvoid callback hellCommon interface to use in the codeTaming side-effects

ComplexityEnumerable 51 Operators

EnumerableEx from Ix (Interactive Extensions)31 Operators

Observable131 Operators

Whats a Reactive System?