Reactive extensions

Post on 10-May-2015

2.182 views 3 download

Tags:

description

Dmitry Pasko speech at Ciklum .NET Saturday (Kharkov 21.05.2011)

Transcript of Reactive extensions

Reactive Extensions“democratize cloud”

Dima Pasko

about me

Kharkov – Ciklum (Scale Point) - .NET – podcasts – open source

http://flavors.me/dimapasko

Erik MeijerProfessor at Utrecht

UniversityOne of the designers

of HaskellMicrosoft Architect LINQVoltaRx

Rx mission“Rx is a library for composing

asynchronous and event-based programs using observable collections.”

Rx current version• Base interfaces in BCL .NET 4• Stable version: v1.0.10425• Experimental Release: v1.1.10425• Last update: April 28, 2011• http://msdn.microsoft.com/en-us/

data/gg577609

Rx for.NET

.NET 3.5 .NET 4

Silverlight Silverlight 3 Silverlight 4 Windows Phone

Java script

“asynchronous”

“observable”interface IEnumerable<out T>{ IEnumerator<T> GetEnumerator();}

interface IEnumerator<out T> : IDisposable{ bool MoveNext(); T Current { get; } void Reset();}

interface IObservable<out T>{ IDisposable Subscribe(IObserver<T> observer);}

interface IObserver<in T>{ void OnNext(T value); void OnError(Exception ex); void OnCompleted();}

Environment

MoveN

ex

tGot next?

Application

On

Next

Have next!

IEnumerable<T>

IEnumerator<T>

IObservable<T>

IObserver<T>

Inte

racti

ve R

eactiv

e

IDisposableinterface IObservable<out T>{ IDisposable Subscribe(IObserver<T> observer);}

interface IObserver<in T>{ void OnNext(T value); void OnError(Exception ex); void OnCompleted();}

demo #1Simple example

exception handlingObservable.Catch()

Observable.Throw()Observable.Retry()Observable.Timeout()

demo #2Exception handling

“composing”• Linq(Where, Take, Skip, Sum, Max,

Any, …)• Statements(If, Case, For, While,

DoWhile)• Combinators(Merge, Zip, Amb, …)• Exceptions(Catch, Retry, ..)• Rx(Delay, Throttle, Interval, Publish,

…)

“event-based”Observable.FromEventPattern()Observable.FromAsyncEventPattern()

ISchedulerObservable.OnserveOn()Observable.SubscribeOn(Scheduler.Tas

kPool)

demo #3Big demo!!!

Rx unit testing

more RxRx Contrib

http://rxcontrib.codeplex.com/ Reactive Extensions - Extensions (Rxx)

http://rxx.codeplex.com/ Rx Power Toys

http://rxpowertoys.codeplex.com/

examples

ReactiveUI

http://www.reactiveui.net/

domain events

http://chaliy.name/archive/2010/1/business_logic_rx_example

TweetSharp.Rx

https://github.com/jhollingworth/TweetSharp.Rx

Rx in books

out of scope• Hot&Cold• Marble diagrams• Linq2PowerShell, Linq2WMI• IQbservable<T>

(IQueryable<T> + IObservable<T>)

• ISubject, Subject<T>• ReactiveJS

informationRx team blog

http://blogs.msdn.com/rxteamDevLabs

http://msdn.microsoft.com/en-us/devlabs/ee794896.aspxMSDN forums

http://social.msdn.microsoft.com/Forums/en-US/rxChannel9

http://channel9.msdn.com/Tags/RxWiki

http://rxwiki.wikidot.com

summary

questionsdimapasko@gmail.compad@ciklum.net

@dimapasko