introduction to rx n.
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to Rx PowerPoint Presentation
Download Presentation
Introduction to Rx

Loading in 2 Seconds...

play fullscreen
1 / 26

Introduction to Rx - PowerPoint PPT Presentation

  • Uploaded on

Introduction to Rx. Reactive Extension to .NET. What is Rx?. Observer pattern implementation . Hollywood principle Allows you to provide delegates to be called by another object. Favours Functional over OO. Plenty of extension methods Encourages monadic programming. Multiple targets.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Introduction to Rx' - kenny

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction to rx

Introduction to Rx

Reactive Extension to .NET

observer pattern implementation
Observer pattern implementation

Hollywood principle

Allows you to provide delegates to be called by another object

favours functional over oo
Favours Functional over OO

Plenty of extension methods

Encourages monadic programming

multiple targets
Multiple targets

.NET 3.5

.NET 4.0

Silverlight 3

Silverlight 4

Windows Phone


linq benefits
Linq benefits







why rx
Why Rx?

Why would you use Rx and why do you care?

asynchronous data
Asynchronous Data

Data being pushed

Async requests

responsive ui
Responsive UI

WPF or Silverlight GUIs


composition of streams of data
Composition of streams of data
  • Concatenation
    • Concat, OnError/Catch, Retry
  • Merging streams
    • Merge, Zip, SelectMany, Amb, CombineLatest, ForkJoin
  • Grouping stream data
    • GroupBy, Window, Buffer, GroupJoin
so what observer pattern is old news what? Observer pattern is old news

Observer pattern is ~15years old

Java has already got the interface

.NET has events


The Java interface is bloated

.NET events are pretty silly.

core bits of rx1
Core bits of Rx



ISubject<T1, T2>

Factory Methods

Extension Methods

Scheduling and Concurrency

iobserver t

namespace System


public interface IObserver<in T>


void OnNext(T value);

void OnError(Exception error); void OnCompleted();



iobservable t

namespace System


public interface IObservable<out T>



IObserver<T> observer);






public interface ISubject<in T1, out T2> 

: IObserver<T1>,

IObservable<T2>{  }

public interface ISubject<T> 

: ISubject<T, T>, 


IObservable<T>{ }


factory methods
Factory Methods

Generate / GenerateWithTime

Range / Interval

Create / CreateWithDisposable

Empty / Return / Never / Throw

FromAsyncPattern / FromEvent

extension methods
Extension Methods
  • Aggregates
    • Aggregate, Sum, Count, Max, Min, First, Last...
  • Filter
    • Where, Skip, Take, First, Last
  • Grouping
    • Window, Buffer, GroupJoin
  • Composition
    • Concat, Merge,
  • Flow control
    • Amb, Case, If, While
scheduling and concurrency
Scheduling and Concurrency



public interface IScheduler


DateTimeOffset Now { get; }

IDisposableSchedule(Action action);


Action action,




scheduler implementations
Scheduler implementations

namespace System.Concurrency


public static class Scheduler


public static ImmediateScheduler Immediate;

public static CurrentThreadSchedulerCurrentThread;

public static ThreadPoolSchedulerThreadPool;

public static NewThreadSchedulerNewThread;

public static TaskPoolSchedulerTaskPool;

public static DispatcherScheduler Dispatcher;






who would benefit
Who would benefit?
  • WPF/Silverlight developers
    • Allowing Rx to schedule work on to the ThreadPool/TaskPool
    • Return results on the dispatcher
    • Easily testable (without pushing a Dispatcher frame!)
  • Serverside teams working on streaming data (finance, instrumentation)
    • Compose many feeds
    • Easily testable
    • IQbservable may allow you to send the declaration to the server to process (GPUs/FSharp expressions)
best practices
Best Practices

Use marble diagrams (esp first 12 months)

Honour the Completion contracts

Apply scheduling only at the end consumer

Avoid breaking the monad (.First() etc)

Avoid Side effects (or be explicit via .Do())

Favour composition over creating new operators

Avoid use of Subjects, favour factories.

Google “Rx Design Guidelines”

thanks to
Thanks to...

Mitch Wheat

Erik Meijer’s team at Microsoft


more content
More content

Data Developer Center(for the download or get via Nuget) (or just talk to James)

Rx Forums (which is the same as talking to James)