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)
          .Do(s => LoadingIndicator.Visibility = Visibility.Visible)
          .SelectMany(txt => searchTwitter(txt))
          .Select(searchRes => ParseTwitterSearch(searchRes))
          .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))
          .Do(tweet => AddTweets(tweet))
          .Do(tweets => UpdateLastTweetId(tweets))
          .SelectMany(tweets => tweets)
          .SelectMany(tweet => ParseTweetToUKSnow(tweet))
          .SelectMany(snowTweet => searchBing(snowTweet))
          .Subscribe(geoTweet => AddSnow(geoTweet));

// every 5 minutes remove old snow from the map
          .Subscribe(i => RemoveOldSnowFromMap());
blog comments powered by Disqus