The following are a couple of examples to accompany my codeproject article on Reactive Extensions. You can read all about them, and download their source from the codeproject page.
Twitter Instant
A Google Instant style twitter search, type in some text to search Twitter:
‘powered’ by the following Rx pipeline:
Observable.FromEvent<TextChangedEventArgs>(searchTextBox, "TextChanged") .Select(e => ((TextBox)e.Sender).Text) .Where(text => text.Length > 2) .Do(s => searchResults.Opacity = 0.5) .Throttle(TimeSpan.FromMilliseconds(400)) .ObserveOnDispatcher() .Do(s => LoadingIndicator.Visibility = Visibility.Visible) .SelectMany(txt => searchTwitter(txt)) .Select(searchRes => ParseTwitterSearch(searchRes)) .ObserveOnDispatcher() .Do(s => LoadingIndicator.Visibility = Visibility.Collapsed) .Do(s => searchResults.Opacity = 1) .Subscribe(tweets => searchResults.ItemsSource = tweets); |
UKsnow – Twitter / Bing Maps mashup
The application below gives a real-time view of the snow across the UK. To add a snow report to the map, tweet #uksnow with your postcode and the amount of snowfall out of ten (e.g. 7/10).
‘powered’ by the following Rx pipelines:
// the uksnow twitter / bing mashup pipeline Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(30)) .SelectMany(ticks => searchTwitter("%23uksnow", _lastTweetId)) .Select(searchResult => ParseTwitterSearch(searchResult)) .ObserveOnDispatcher() .Do(tweet => AddTweets(tweet)) .Do(tweets => UpdateLastTweetId(tweets)) .SelectMany(tweets => tweets) .SelectMany(tweet => ParseTweetToUKSnow(tweet)) .SelectMany(snowTweet => searchBing(snowTweet)) .ObserveOnDispatcher() .Subscribe(geoTweet => AddSnow(geoTweet)); // every 5 minutes remove old snow from the map Observable.Timer(TimeSpan.FromMinutes(5)) .ObserveOnDispatcher() .Subscribe(i => RemoveOldSnowFromMap()); |


email: ceberhardt@scottlogic.co.uk
on Google+



Exploring Reactive Extensions (Rx) through Twitter and Bing Maps Mashups | Colin Eberhardt’s Adventures in WPF…
Thank you for submitting this cool story – Trackback from DotNetShoutout…