Demos and sample for Reactive Extensions. Includes example of using Rx as a real-time OLAP cube
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Real World Reactive Extensions.pptx

Code to accompany Intro to Reactive extentions talk

#LinqPad Demos

  1. [BackgroundThread](LinqPadSamples/01 BackgroundThread.linq)
  2. [ThreadSafe](LinqPadSamples/01 ThreadSafe.linq)
  3. [ColdEnumerable]("LinqPadSamples/02 ColdEnumerable.linq")
  4. [ColdObservable]("LinqPadSamples/03 ColdObservable.linq")
  5. [HotObservable]("LinqPadSamples/04 HotObservable.linq")
  6. [Create]("LinqPadSamples/06 Create.linq")
  7. [CreateDisposable]("LinqPadSamples/06 CreateDisposable.linq")
  8. [GenerateWithTime]("LinqPadSamples/07 GenerateWithTime.linq")

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?