views:

3360

answers:

8

Aside from the Microsoft documentation, does anyone know of a good introduction and tutorial to the Microsoft Reactive (Rx) framework?

Also, could someone articulate a good example (with code) of a programming problem that is challenging to solve using conventional asynchronous coding techniques that Reactive makes easier.

+1  A: 

You may find these series of articles (there are 4) about reactive linq may be useful: http://tomasp.net/blog/reactive-ii-csevents.aspx

He has an example of writing a game using it, so it should hopefully be what you are looking for.

James Black
+2  A: 

Does your "excluding Microsoft documentation" clause extend to the videos on Channel 9?

From the creator of the reactive framework Erik Meijer: - Expert to Expert: Brian Beckman and Erik Meijer - Inside the .NET Reactive Framework (Rx)

Brand new: Getting Started with Rx Extensions for .NET

Matt Breckon
also http://channel9.msdn.com/shows/Going+Deep/Kim-Hamilton-and-Wes-Dyer-Inside-NET-Rx-and-IObservableIObserver-in-the-BCL-VS-2010/
Matt Breckon
+3  A: 

Hello,

I also found following link on CodeBetter.com Introducing the Reactive Framework Part I

There is a sequel to the first part on the same site.

Hope this will help you.

FrenchData
+2  A: 

Here's an example of something that is easy to do with reactive programming, but messy (if not challenging) with classic events, it draws lines while the mouse button is down. It is readable, there is no explicit state handling:

var pen = new Pen(Color.Red, 3);
var graphics = this.CreateGraphics();

var mouseMoveWhileDown = 
    from md in this.GetMouseDown()
    from mv in this.GetMouseMove().Until(this.GetMouseUp())
    select new Point(mv.X, mv.Y);

mouseMoveWhileDown
    .Pairwise()
    .Subscribe(tup => graphics.DrawLine(pen, tup.Item1, tup.Item2));

(I must confess that in that example, Pairwise() is home-grown...)

The most important thing about IObservable is that it is 'composable', just like IEnumerable.

I thouroughly recommend the video mentioned in another answer. In fact there are several different videos on the subject on Channel9:

Benjol
Where does .Until come from, I can never use it, I must be missing a reference
TimothyP
@TimothyP, I think it might be a throwback to an older version. That or I wrote one myself (I was playing with implementing IObservable extension methods at the time). From what I can see, the latest version of reactive extensions has a method called `TakeUntil`, which looks like a good fit.
Benjol
+1  A: 

Go through these articles, and in particular, download the related source code and play with it.

Trust this will help

amazedsaint
+12  A: 

Here's a wiki site with lots of code examples demonstrating how to us different features of the .NET Rx framework: http://rxwiki.wikidot.com/101samples

I found this to be the most comprehensive site out there, and the one that's quickest to get started with.

LBushkin
So far as I can tell this wiki doesn't so much as tell you which reference to include. Which is rather...frustrating.
George Mauer
+3  A: 

Once you have gone through some of the basic stuff including the HandsOnLab make sure you check out Lee Campbell's Hot and Cold Observables which took some of the arcane mystery out of Rx for me :)

sweetlilmre