Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good introduction to the .NET Reactive Framework [closed]

People also ask

What is Rx in c#?

Basically, Rx is a library for composing asynchronous and event-based programs using observable collections. This is very useful in the case wherein you are pulling data asynchronously from different sources and then manipulating the same and finally printing the result.

What is a reactive framework?

Reactive frameworks, also known as reactive programming frameworks, are created with the express purpose of expressing application logic through streams that trigger what is known as side-effects.

What is Rx Net?

Rx.NET: (this repository) The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators.


UPDATE: The blog posts below have been superseded by my online book www.IntroToRx.com. It is a comprehensive 19 chapter book available for free. You can browse it on the web, or download the mobi version for your kindle. You can also get it direct from Amazon for a tiny fee (~99c / 77p). If the book doesn't meet your needs or expectations, let me (the Author) know and we will do better for v2.

Thanks for the link to the Hot/Cold post. This is only one part of the full series,

  1. Introduction to Rx
  2. Static and extension methods
  3. Lifetime management – Completing and Unsubscribing
  4. Flow control
  5. Combining multiple IObservable streams
  6. Scheduling and threading
  7. Hot and Cold observables
  8. Testing Rx
  9. Buffer, Window, Join and Group Join

I will keep updating this blog with more Rx introductory stuff.

For more advanced stuff you want to go to the Rx Forum (MSDN).


Here's a wiki site with lots of code examples demonstrating how to use 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.


MSDN Site for Rx-Framework

For a Developer going deeper, the Source Code

Cool Austrian keynote about Rx

This is the best I have seen: DevCamp 2010 Keynote - Rx: Curing your asynchronous programming blues

Some interesting Videos on Channel 9

Kim Hamilton and Wes Dyer: Inside .NET Rx and IObservable/IObserver in the BCL (VS 2010)

An interview with the creator from Rx: Expert to Expert: Brian Beckman and Erik Meijer - Inside the .NET Reactive Framework (Rx)

An introduction from the creator of Rx

An Codeproject Article

Another course first blog with links (new)


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:


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 :)


You may find this series of articles (there are four) about reactive LINQ useful: Reactive programming (II.) - Introducing Reactive LINQ.

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