Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created November 16, 2010 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anaisbetts/702099 to your computer and use it in GitHub Desktop.
Save anaisbetts/702099 to your computer and use it in GitHub Desktop.
IObservable<IDictionary<string, bool>> ValidateManyUrisAsync(string[] Uris)
{
// Aggregate will take a "future list" and return a future with only one item
// (Just like LINQ's Aggregate takes a list and returns a single value)
// For every result that ValidateUrlAsync provides, we will execute the
// Aggregate block. When SelectMany completes, Aggregate can finally
// return its one result
return Uris.ToObservable()
.SelectMany(x => ValidateUriAsync(x))
.Aggregate(new ConcurrentDictionary<string, bool>(), (acc, pair) => {
acc.TryAdd(pair.Key, pair.Value);
return acc;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment