AWS Community Day CPH - Three problems of Terraform
Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
1. Creating a simple Doodle (drawing) like application using Silverlight and Reactive Framework (RX) Matt Duffield, MVP, MCSD .NET http://mattduffield.wordpress.com @mattduffield
2. What is the Reactive Framework? IEnumerator IObserver IObserver modes Rx keywords Demo code What we are going to cover
3. Rx is a library for composing asynchronous and event-based programs using observable collections. Where can I use Rx? .NET Framework 3.5 SP1, 4 Silverlight 3, 4, 5 Windows Phone 7 XNA 4.0 for Xbox 360 Zune JavaScript What is the Reactive Framework?
4. Asynchronous and event-based – as reflected in the title, the bread and butter of Rx’s mission statement is to simplify those programming models. Composition – combining asynchronous computations today is way too hard. It involves a lot of plumbing code that has little to nothing to do with the problem being solved. Observable collections – by looking at asynchronous computations as data sources, we can leverage the active knowledge of LINQ’s programming model. Three core properties
5.
6. Stock tickers RSS feeds Social media UI events GPS Server management Why does it help?
7.
8.
9.
10.
11.
12.
13.
14.
15.
16. public interface IEnumerator { object Current { get; } boolMoveNext(); void Reset(); } Because we are waiting/”pulling” for a return value, these are blocking. IEnumerator
17. public interface IObserver<T> { void OnNext(T value); void OnError(Exception ex); void OnCompleted(); } We get “pushed” when a new value is available. IObserver
18. Hot – typically values that come in from events or a web service Cold – known list of values from a collection, array, etc. IObserver modes
19. FromEventPattern<T,U> Merge SkipUntil TakeUntil Throttle ObserveOn(Schedular.ThreadPool) Do TimeInterval – allow us to test for something over time Subject<> FromAsnyncPattern<T,U> Rx Keywords
21. Reactive Extensions http://msdn.microsoft.com/en-us/data/gg577609 Erik Meijer and Wes Dyer Reactive Framework (RX) Under the Hood 1 of 2 http://channel9.msdn.com/Shows/Going+Deep/E2E-Erik-Meijer-and-Wes-Dyer-Reactive-Framework-Rx-Under-the-Hood-1-of-2 Erik Meijer and Wes Dyer Reactive Framework (RX) Under the Hood 2 of 2 http://channel9.msdn.com/Shows/Going+Deep/E2E-Erik-Meijer-and-Wes-Dyer-Reactive-Framework-Rx-Under-the-Hood-2-of-2 Bart de Smet http://channel9.msdn.com/Blogs/joshholmes/Bart-de-Smet-in-Dublin-on-the-Rx-Framework Jim Wooley – ThinqLinq http://www.thinqlinq.com/ http://live.visitmix.com/MIX11/Sessions/Speaker/Jim-Wooley References
Asynchronous and event-based – As reflected in the title, the bread and butter of Rx’s mission statement is to simplify those programming models. Everyone knows what stuck user interfaces look like, both on the Windows platform and on the web. And with the cloud around the corner, asynchrony becomes quintessential. Low-level technologies like .NET events, the asynchronous pattern, tasks, AJAX, etc. are often too hard. Composition – Combining asynchronous computations today is way too hard. It involves a lot of plumbing code that has little to nothing to do with the problem being solved. In particular, the data flow of the operations involved in the problem is not clear at all, and code gets spread out throughout event handlers, asynchronous callback procedures, and whatnot. Observable collections – By looking at asynchronous computations as data sources, we can leverage the active knowledge of LINQ’s programming model. That’s right: your mouse is a database of mouse moves and clicks. In the world of Rx, such asynchronous data sources are composed using various combinators in the LINQ sense, allowing things like filters, projections, joins, time-based operations, etc.