creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

21
Creating a simple Doodle (drawing) like application using Silverlight and Reactive Framework (RX) Matt Duffield, MVP, MCSD .NET http://mattduffield.wordpress.com @mattduffield

Upload: matthew-duffield

Post on 10-May-2015

1.203 views

Category:

Technology


4 download

DESCRIPTION

A presentation on building a simple doodle application using the Reactive Extensions framework in Silverlight.

TRANSCRIPT

Page 1: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

Creating a simple Doodle (drawing) like application using Silverlight

and Reactive Framework (RX)

Matt Duffield, MVP, MCSD .NEThttp://mattduffield.wordpress.com

@mattduffield

Page 2: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

What is the Reactive Framework? IEnumerator IObserver IObserver modes Rx keywords Demo code

What we are going to cover

Page 3: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

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?

Page 4: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

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

Page 5: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 6: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

Stock tickers RSS feeds Social media UI events GPS Server management

Why does it help?

Page 7: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 8: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 9: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 10: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 11: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 12: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 13: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 14: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)
Page 15: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

public interface IEnumerator{

object Current { get; }bool MoveNext();void Reset();

}

Because we are waiting/”pulling” for a return value, these are blocking.

IEnumerator

Page 16: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

public interface IObserver<T>{

void OnNext(T value);void OnError(Exception ex);void OnCompleted();

}

We get “pushed” when a new value is available.

IObserver

Page 17: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

Hot – typically values that come in from events or a web service

Cold – known list of values from a collection, array, etc.

IObserver modes

Page 18: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

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

Page 19: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

Demo

Page 20: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

Reactive Extensionshttp://msdn.microsoft.com/en-us/data/gg577609Erik Meijer and Wes Dyer Reactive Framework (RX) Under the

Hood 1 of 2http://channel9.msdn.com/Shows/Going+Deep/E2E-Erik-Meijer-and-Wes-Dyer-Reactive-Framework-Rx-Under-the-Hood-1-of-2Erik Meijer and Wes Dyer Reactive Framework (RX) Under the

Hood 2 of 2http://

channel9.msdn.com/Shows/Going+Deep/E2E-Erik-Meijer-and-Wes-Dyer-Reactive-Framework-Rx-Under-the-Hood-2-of-2

Bart de Smethttp://channel9.msdn.com/Blogs/joshholmes/Bart-de-Smet-in-Dublin-on-the-Rx-FrameworkJim Wooley – ThinqLinqhttp://www.thinqlinq.com/http://live.visitmix.com/MIX11/Sessions/Speaker/Jim-Wooley

References

Page 21: Creating a simple doodle (drawing) like application using silverlight and reactive framework (rx)

Questions?

Matt Duffield, MVP, MCSD .NEThttp://mattduffield.wordpress.com

@mattduffield