Rx Workshop: Unified Programming Model

Sign in to queue

The Discussion

  • User profile image

    a pitty that nobody posted anything on te challange (or am I missing something?) so here is my *take* on it:

                // Convert txt.TextChanged to IObservable<EventPattern<EventArgs>> and assign it to textChanged.
                var textChanged =
                        .FromEventPattern(addHandler: evHandler => txt.TextChanged += evHandler,
                                          removeHandler: evHandler => txt.TextChanged -= evHandler)
                        .Select(ev => ((TextBox) ev.Sender).Text)
                // Convert BeginMatch/EndMatch to Func<string, IObservable<DictionaryWord[]>> and assign it to getSuggestions.
                var getSuggestions = Observable.FromAsyncPattern<string, DictionaryWord[]>(begin: BeginMatch, end: EndMatch);
                var results = from text in textChanged
                              where text.Length >= 3
                              from suggestions in getSuggestions(text)
                              select suggestions;

    As you might see I took the freedom to change some little pieces.

    First I want to get the text from textChanged (just like in the cast) and second I don't want to fire 7 webrequests in succesion to get the suggestions for "automobile" while typing, so I throttle the textChanged-Observable to 300ms.

  • User profile image
    c t

    This is fun!


    var textChanged = Observable.FromEventPattern<EventArgs>(txt, "TextChanged");

    var getSuggestions = Observable.FromAsyncPattern<string, DictionaryWord[]>(BeginMatch, EndMatch);


  • User profile image

    Haven't watch the video yet, but, I like what has been promised from the summary. And a lot of rainbows Big Smile.

  • User profile image

    As more of an assembler, rather than programmer or developer, I just kept removing things and plugging different things together and it actually worked first time!?! So here is my effort.

    var textChanged = Observable.FromEventPattern(txt, "TextChanged");
    var getSuggestions = Observable.FromAsyncPattern<string, DictionaryWord[]>(BeginMatch, EndMatch);


  • User profile image

    I'm trying to follow along with this example using VB. This is the code I have :
    Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    Dim res = From evt In Observable.FromEventPattern(TextBox1, "TextChanged")
    Select CType(evt.Sender, TextBox).Text

    res.Subscribe(Function(s) Me.Text = s)

    End Sub
    End Class

    I get no errors but nothing happens. What am I doing wrong ?

Add Your 2 Cents