Demos and sample for Reactive Extensions. Includes example of using Rx as a real-time OLAP cube
Latest commit 3629114 Dec 31, 2011 @ScottWeinstein readme update
Failed to load latest commit information.
DisplayUpdates use fake twitter by default Dec 31, 2011
FileSystemStreamingOLAPDemo * upgrades Dec 31, 2011
ImplementWhereDemo * upgrades Dec 31, 2011
LinqPadSamples fix refs Jul 19, 2011
PollingWS * upgrades Dec 31, 2011
SimpleTemperatureAlerts * upgrades Dec 31, 2011
.gitignore update pres Jul 16, 2011
BuildPres.ps1 update pres Jul 16, 2011 readme update Dec 31, 2011
Real World Reactive Extensions.pptx
Rx-Demos.sln * upgrades Dec 31, 2011
rx.msbuild * upgrades Dec 31, 2011

Code to accompany Intro to Reactive extentions talk

LinqPad Demos

  1. BackgroundThread
  2. ThreadSafe
  3. ColdEnumerable
  4. ColdObservable
  5. HotObservable
  6. Create
  7. CreateDisposable
  8. GenerateWithTime

VisualStudio Demos

Querying a server

  1. A slow or expensive query
  2. On a background loop
  3. With user initiated action, for the impatient
  4. But not too often
  5. Compare the ad-hoc w/ the Rx approach

UI for password check

  1. Accept correct password
  2. Reject incorrect
  3. No "submit button"
  4. Timeout
  5. Must be unit testable

Twitter client

  1. Need to make an IO from a traditional API
  2. Want a mock version for UI development
  3. Only want to show latest for each user
  4. Want late subscribers to have latest values

Streaming Olap


  • What's the Rx thing about, why should I care?
  • Will it make my life easier?
  • What's new in 1.0

What's the Rx thing about, why should I care?

  • For some, Rx is something of a revelation.
  • A good way to deal with asynchronous code
  • A good way to deal with event based code
  • A good way to deal with concurrent code
  • A good way to deal with time sensitive code

Reactive matters

  • Systems and architectures that are not reactive are legacy systems
    • Real life is async
    • Sync, ie, blocking activities are souces of real stress
      • waiting in line for coffee, the elevator, the check to clear, etc
  • Batch, pull, polling, request/response were common b/c building asyncronous code was (much) harder

  • Till now...

A good way?

  • Composable
  • Testable
  • Pure (side-effect free)

Two use cases

  1. Managing a bar
  2. Calling a web service async

So what is Rx?

  • A new Interface pair IObservable<T> and IObserver<T> for .Net BCL
    • The dual of IEnumerable<T> and IEnumerator<T>
  • A core implementation and a set of Linq combinators for doing useful things

A look at some recent Rx questions

Open questions?

More Details - IEnumerable and IEnumerator

interface IEnumerable<T>
    IEnumerator<T> GetEnumerator();

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

More Details - IObservable and IObserver

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

interface IObserver<T>
    void OnCompleted(); 
    void OnError(Exception error);  
    void OnNext(T value);

Pop Quiz - Hot or Not?


Pop Quiz - Hot or Not?

  1. new[] { 1, 2, 3, 4 }
  2. new List<string>()
  3. Enumerable.Range(1, Int32.MaxValue)
  4. new int[Int32.MaxValue]
  5. People.Where(pers => pers.Age >= 21)
  6. Observable.Range(1,3)
  7. Observable.FromEvent("Click")


  • Avoid implementing IObservable from scratch
  • Hot or not?