Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Rx Workshop: Unified Programming Model

Download

Right click “Save as…”

Learn how to wrap existing event sources, including tasks, asynchronous methods, .NET events, etc. in observable sequences.

Download the Challenge

Tags:

Follow the Discussion

  • CKoenigCbrAInK Carsten

    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 =
                    Observable
                        .FromEventPattern(addHandler: evHandler => txt.TextChanged += evHandler,
                                          removeHandler: evHandler => txt.TextChanged -= evHandler)
                        .Select(ev => ((TextBox) ev.Sender).Text)
                        .Throttle(TimeSpan.FromMilliseconds(300));
    
                // 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.

  • c tc t

    This is fun!

    <csharp>

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

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

    </csharp>

  • magicalclickmagicalclick C9 slogan, #dealwithit. WinPh8.1 IE empty tab crash and removable video control edition.

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

  • ChevalN2Cheval Why not null?

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

     

  • LaurenLauren

    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 ?
    Thanks

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.