Rx Hands-On Labs published RRS feed

  • General discussion

  • Hi folks,

    Today, we released two hands-on labs on Rx both for .NET and for JS. The goal of those two documents is to present the reader with a gentle introduction into the subject, based on a series of incremental samples. This is based on a series on internal presentations we gave on the subject, being extended to various upcoming internal training events. Obviously we like to share this with the community, so here are the pointers:

    Enjoy! As usual, all feedback is welcome. The idea is to evolve those documents based on feedback from different channels.


    using (Microsoft.Sql.Cloud.DataProgrammability.Rx) { Signature.Emit("Bart De Smet"); }
    Wednesday, July 7, 2010 6:43 AM

All replies

  • The example of Generate on page 9 of the .NET version is wrong.
        IObservable<int> source = Observable.Generate(0, i => i < 5, i => i + 1, i => i * i);
    generates the infinite stream of 1. The selector and the iterate functions are in the wrong order. It should be
      IObservable<int> source = Observable.Generate(0, i => i < 5, i => i * i, i => i + 1);


    Wednesday, July 7, 2010 1:24 PM
  • Ah yes, Bart didn't mention these docs are using the upcoming release of Rx. In this release the order of the arguments of the Generate* methods are changed to match the for-statement more closely, this was done based on feedback from the C# team.
    Wednesday, July 7, 2010 6:01 PM
  • I've also just hit this.

    Perhaps designing an expression that works either way for the example?

    Richard J Cox
    Wednesday, July 7, 2010 6:13 PM
  • Good job Bart.

    This stuff has been missing from the Rx community and it is great to see clear and thorough guidance coming from the team themselves.


    Keep up the good work.

    Lee Campbell


    My attempts at this kind of stuff live here plus the following posts with more to come.

    Thursday, July 8, 2010 8:14 AM
  • Great, something I have been looking for a long time to reference in delivery documents.

    Werk uitstekend gedaan... ;-)


    Thursday, July 8, 2010 9:31 AM
  • There's also the invalid code
      IDisposable subscription = source.Run

    I think this is a good introduction.

    I hope I'm not misunderstanding how the observables are wired together, but one issue I would like to have seen covered is how the pattern

       for term in input
       from workItem in someGenerator(term).TakeUntil(input)
       select workItem

    puts certain requirements on the input observable. More importantly, whenever you subscribe multiple times to the same Observable, you enter the world of threading. The document mentions that F# uses a single thread for processes, and dismisses this as too limiting. It then goes on to use this pattern in a context where we rely on both subscribers to the TextChanged being called before the next TextChanged is raised.

    For example, if input is a cold Observable.Interval, then you get two timer instances that might well fire out of phase (or get delayed by the thread pool) ie the Observable for the "for term in input" could fire several times before the timer used by the TakeUntil possibly leading to strange results. Using Switch, to get a single subscription, would get rid of some of these issues.

    Thursday, July 8, 2010 9:43 AM
  • Noticed a second issue.

    In exercise 3, step 4 just pasting in the code will given an error on the Subscribe code. In step 2 there is no "using System", so in step 4 there is no extension Subscribe method taking a single delegate.

    Richard J Cox


    (Edit: s/step 3/step 4/)

    • Edited by RichardCox Thursday, July 8, 2010 11:06 AM Typo
    Thursday, July 8, 2010 11:00 AM
  • And another issue, this one is more complex. At the of exercise 5, the following helper is suggested:

    public static IObservable<T> LogTimestampedValues(this IObservable<T> source, Action<T> onNext)
       return source.Timestamp().Do(onNext).RemoveTimestamp();

    This contains two errors:

    1. No <T> after the method name.
    2. The delegate onNext needs to have type Action<Timestamped<T>>.

    The corrected code:

    public static IObservable<T> LogTimestampedValues<T>(this IObservable<T> source, Action<Timestamped<T>> onNext) {
       return source.Timestamp().Do(onNext).RemoveTimestamp();

    Richard J Cox
    Friday, July 9, 2010 10:27 PM
  • Hi folks,

    We really appreciate the active feedback. Some suggestions have been incorporated now. The links have been updated to refer to the new documents that have the changes applied.



    using (Microsoft.Sql.Cloud.DataProgrammability.Rx) { Signature.Emit("Bart De Smet"); }
    Tuesday, July 13, 2010 9:04 AM
  • Hi Bart,

    it would be great if you included links to the Rx HOLs in the forum "Announcements" and on the Rx DevLab page!


    Tuesday, July 13, 2010 9:18 AM
  • For anyone that's interested, the HOL are now available in VB.Net at HOL .NET VB.pdf. - "LINQ In Action", The book is now available. Don't wait for the movie
    Thursday, August 26, 2010 1:32 AM