1 / 36

An Introduction to the Reactive Extensions

An Introduction to the Reactive Extensions. Ivan Towlson Mindscape. Reintroducing LINQ. Composable operators for working with sets of data. IEnumerable : the little interface that could. IQueryable : the little interface that takes twelve years to implement.

kapila
Télécharger la présentation

An Introduction to the Reactive Extensions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Introduction to theReactive Extensions Ivan Towlson Mindscape

  2. Reintroducing LINQ Composable operators for working with sets of data

  3. IEnumerable:the little interface that could

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

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

  6. Introducing IObservable

  7. interface IEnumerable<T> { IEnumerator<T> GetEnumerator(); } interface IObservable<T> { IDisposable Subscribe(IObserver<T>); }

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

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

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

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

  12. Introducing theReactive Extensions 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

  13. Where does asynchronous data come from?

  14. Events as asynchronous data

  15. Revisiting the asynchronous method pair pattern

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

  17. The pulls pushand the pushers pull with apologies to P J Harvey

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

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

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

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

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

  23. What about timing?What about threading?

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

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

  26. Or we could just do itright here on the UI thread ObserveOn SubscribeOn

  27. A brief interlude for theobligatory eggheadtude Sorry, Visual Basic fans, butthe doors are now locked

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

  29. Orthogonality fail?

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

  31. Introducing IQbservable Also known as IQueryableObservable or IShouldntChooseNamesWhileStoned

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

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

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

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

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

More Related