Posted By: Jeffrey van Gogh | Nov 17th, 2009 @ 11:44 AM | 34,489 Views | 31 Comments
Today we released Reactive Extensions for .NET on DevLabs.

Rx is a .NET Library that allows programmers to write succinct declarative code to orchestrate and coordinate asynchronous and event-based programs based on familiar .NET idioms and patterns.


In this video, Wes Dyer goes through the steps of writing your first Rx Application. The Hello World equivalent of Rx is Drag-and-Drop.
Rating:
11
0
N2Cheval
N2Cheval
Why not null?

Just wow!

 

One question, how well does this play with WPF triggers?

Thanks for making this video.  Can you please post the code for this sample app?  My vision is too poor to be able to read any of the code in the video.

Very cool! Really shows the expressive, declarative nature of Rx. Big improvement over the way we normally do things.

 

How about a video showing asynchronous programming via Rx? 

aL_
aL_
Rx ftw

did you check out the wmv high version? text is much clearer there Smiley

aL_
aL_
Rx ftw

triggers are based on dependency properties, and you could write something that makes a dependecy property into an observable

im working on something like that infact Smiley

 

also @wes, Observable.Context is static, what if i want to have one observable use one context and another observable to use another?

aL_
aL_
Rx ftw

-edit-

this discussion continued on the rx forums where a neater solution was found

-end edit-

 

Hello again, i wrote a little helper class for converting dependency properties to Observable, im not sure its the best way to do it though, what do you guys think? am i missing something? There are some anonymous Observable/disposable in rx that i'd liked to use but they are internal.. i suspect there is something smarter i can do with the Create methods but i coudnt get around making a helper class..

 

public partial class MainWindow : Window {
  public MainWindow( ) {
  InitializeComponent( );
  Observable.Context = SynchronizationContext.Current;
  this.ActualHeightAsObservable( ).Subscribe( d => label1.Content = d );
  }
}

public class DependencyObservable<T> : IDisposable {
  EventHandler eh; DependencyPropertyDescriptor des; object instance;

  public DependencyObservable( IObserver<T> observer, DependencyProperty dp, Type ownertype, object ins ) {
    des = DependencyPropertyDescriptor.FromProperty( dp, ownertype );
    instance = ins;
    eh = new EventHandler( ( o, e ) => observer.OnNext( ( T )des.GetValue( instance ) ) );
    des.AddValueChanged( instance, eh ); 
  }

  public void Dispose( ) {
    des.RemoveValueChanged( instance, eh ); 
  }
}

public static class WindowExtensions {
  public static IObservable<double> ActualHeightAsObservable( this MainWindow w ) {
    return CreateWithDisposable<double>( obs => new DependencyObservable<double>( obs, MainWindow.HeightProperty, 
      w.GetType( ), w ) )
  }
}

 

The nice thing is that the returned observable respects all the rules of Dependency properties, if the dp is changed by a style, trigger or binding, the Observable should reflect that (ive only tried with bindings though)

Flynn0r
Flynn0r
Passionate about code

This video makes it very clear what Rx is capable of. Thanx a lot

@aL_, use .SubscribeOn and .ObserveOn expect more work in the future on this area...

does RX work with asp.net applications too ?

Microsoft Communities