Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Introduction to the Reactive Extensions Ivan Towlson Mindscape.

Similar presentations


Presentation on theme: "An Introduction to the Reactive Extensions Ivan Towlson Mindscape."— Presentation transcript:

1 An Introduction to the Reactive Extensions Ivan Towlson Mindscape

2 Composable operators for working with sets of data Reintroducing LINQ

3 IEnumerable: the little interface that could

4 Extends IEnumerable to support translation of LINQ queries for processing by another engine IQueryable: the little interface that takes twelve years to implement

5 IEnumerable is a pull model Unpredictable streams are better handled by a push model Pulling and pushing

6 Introducing IObservable

7 interface IEnumerable { IEnumerator GetEnumerator(); } interface IObservable { IDisposable Subscribe(IObserver ); }

8 interface IEnumerator { bool MoveNext(); T Current; } interface IObservable { void OnNext(T); void OnError(Exception); void OnCompleted(); }

9 An implementation of the LINQ standard query operators (and more) for the IObservable interface Introducing the Reactive Extensions

10 IEnumerable LINQ to Objects IObservable “LINQ to Events” IQueryable e.g LINQ to SQL Pull (interactive) Push (reactive) Translatable (expression trees) Fixed (MSIL) How? What?

11 A unified, declarative, composable way of working with asynchronous sources Builds on existing sources of asynchrony, rather than replacing them Introducing the Reactive Extensions

12 Like LINQ, Rx doesn’t do anything you couldn’t do in your own code, but it wraps up a lot of boilerplate and ad hoc code into convenient, composable operators Introducing the Reactive Extensions

13 Where does asynchronous data come from?

14 Events as asynchronous data

15 Revisiting the asynchronous method pair pattern

16 Not useful in themselves, but useful for composition Observable.Create: explicitly spelling out the event sequence (like an iterator) Primitive constructors and generators

17 The pulls push and the pushers pull with apologies to P J Harvey

18 IEnumerable LINQ to Objects IObservable “LINQ to Events” IQueryable e.g LINQ to SQL Pull (interactive) Push (reactive) Translatable (expression trees) Fixed (MSIL) How? What? ToXxx AsXxx

19 What can we do with asynchronous data once we’ve got a source?

20 Where Select / SelectMany Count / Any / All and all the rest LINQ operators

21 Scan Buffer (with time and count options) TakeUntil Merge / Amb And a whole lot more besides

22 Sample Throttle / Timeout Timestamp / TimeInterval DistinctUntilChanged And a whole lot more besides

23 What about timing? What about threading?

24 IEnumerable LINQ to Objects IObservable “LINQ to Events” IQueryable e.g LINQ to SQL Pull (interactive) Push (reactive) Translatable (expression trees) Fixed (MSIL) How? What? When? IScheduler

25 Immediate Thread pool, task pool WPF or WinForms UI thread Custom Schedulers

26 ObserveOn SubscribeOn Or we could just do it right here on the UI thread

27 Sorry, Visual Basic fans, but the doors are now locked A brief interlude for the obligatory eggheadtude

28 IEnumerable LINQ to Objects IObservable “LINQ to Events” IQueryable e.g LINQ to SQL Pull (interactive) Push (reactive) Translatable (expression trees) Fixed (MSIL) How? What? dual homoiconic

29 Orthogonality fail?

30 IEnumerable LINQ to Objects IObservable “LINQ to Events” IQueryable e.g LINQ to SQL Pull (interactive) Push (reactive) Translatable (expression trees) Fixed (MSIL) How? What? FILL ME

31 Also known as IQueryableObservable or IShouldntChooseNamesWhileStoned Introducing IQbservable

32 Allows queries to be translated for processing by external push sources Like IQueryable, filtering, aggregation, etc. can be performed at the source Introducing IQbservable

33 LINQ to * IEnumerable LINQ to Objects IObservable “LINQ to Events” IQueryable e.g LINQ to SQL Pull (interactive) Push (reactive) Translatable (expression trees) Fixed (MSIL) How? What? IQbservable e.g. LINQ to WMI

34 .NET, Silverlight: download from MSDN Windows Phone 7: included in ROM but can download updated version JavaScript: download from MSDN Availability

35 MSDN DevLabs – Projects > Rx PDC talk – FT10, Bart de Smet http://blogs.msdn.com/b/rxteam/ Rx Design Guidelines document Resources

36 Thanks! Ivan Towlson ivan@mindscape.co.nz | ivan@hestia.cc http://hestia.typepad.com/flatlander/


Download ppt "An Introduction to the Reactive Extensions Ivan Towlson Mindscape."

Similar presentations


Ads by Google