Rx Workshop: Unified Programming Model
- Posted: Jun 29, 2011 at 8:45 AM
- 36,976 Views
- 5 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
Learn how to wrap existing event sources, including tasks, asynchronous methods, .NET events, etc. in observable sequences.
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.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
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.
This is fun!
<csharp>
var textChanged = Observable.FromEventPattern<EventArgs>(txt, "TextChanged");
var getSuggestions = Observable.FromAsyncPattern<string, DictionaryWord[]>(BeginMatch, EndMatch);
</csharp>
Haven't watch the video yet, but, I like what has been promised from the summary. And a lot of rainbows
.
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.
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