An Introduction to Reactive Extensions. Demo Code available at http://github.com/james-world/rxtalk.
Note: Most of these slides were willfully plagiarised from slides and bits of demos done by the Rx-Team themselves, and repurposed to fit into a 20 minute datablast! Special thanks to the awesome Erik Meijer and Bart de Smet whose permission I didn't seek... I hope they don't mind!
2. A library for the composition of asynchronous and
event-based programs using observable
sequences and LINQ-style operators.
3. interactive streams
public interface IEnumerable<out T> : IEnumerable
{
IEnumerator<T> GetEnumerator();
}
public interface IEnumerator<out T> : IDisposable, IEnumerator
{
bool MoveNext();
T Current { get; }
void Reset();
}
4. composability
var openOrders =
from customer in context.Customers
from order in customer.Orders
where customer.CustomerId == 101
where order.Status == OrderStatus.Open
select order;
20. async Task<string> GetHtmlAsync(Uri url)
{
var client = new WebClient();
var download = client.DownloadStringAsync(url);
var timeout = Task.Delay(TimeSpan.FromSeconds(30));
if (await Task.WhenAny(download, timeout) == timeout)
throw new TimeoutException();
var html = await download;
return html;
}
async without Rx
21. async Task<string> GetHtmlAsync(Uri url)
{
var client = new WebClient();
var download = client.DownloadStringAsync(url)
.ToObservable()
.Timeout(TimeSpan.FromSeconds(30));
var html = await download;
return html;
}
async with Rx