Your SlideShare is downloading. ×
0
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Reactive Extensions
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Reactive Extensions

3,170

Published on

Slides from the 20th meeting of the St. Petersburg Alt.Net User Group

Slides from the 20th meeting of the St. Petersburg Alt.Net User Group

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,170
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
65
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Dmitri Nesteruk dmitri@activemesa.com http://activemesa.com http://spbalt.net Based on materials by Scott Weinstein
  • 2. Multiple data items can be “processed” in either a push or a pull fashion. In a pull paradigm, data is processed at the leisure of the destination. Common examples include: reading from a file summing the numbers in an array iterating though a database query traversing a directory listing paging through an Amazon search
  • 3. In a push paradigm, data is processed via demands of the source. Common examples include: Device measurements such as time light heat User triggered data such as Mouse & Keyboard events UI events Sales transactions Asynchronous code
  • 4. In .Net Pulled data is exposed via a single core interface IEnumerable/IEnumerator Pushed data is exposed via Events Ad-hoc delegate callbacks Ad-hoc subscribe/callback interfaces BeginXXX/EndXXX Async pattern 3rd party attempts at Linq for Pushed data (Clinq, Slinq, PushLinq) Each implementation is unique is it’s own way
  • 5. LINQ provides a composable, and standard way to do list manipulations The Reactive Extensions (RX) attempt to Provide a common interface for Pushed data IObservable/IObserver Enable Linq over Pushed data, providing composiblity and standard operators
  • 6. Available for free from Domains MS DevLabs Events http://bit.ly/reext APM Support for Web service calls .Net 3.5 SP1 Async workflows .Net 4 Task<T>-based calls Silverlight 3 Applications JavaScript Web page d/l Not part of .Net 4 :( Async file IO Except the interfaces Streaming OLAP
  • 7. 5 assemblies (including PFX) System.CoreEx Feel free to ILmerge Main features System.Interactive Interfaces (IObserver<T>, IObservable<T>) System.Observable Observer conversions LINQ support System.Reactive WinForms & WPF notification support System.Threading (PFX) Infrastructure No particular namespace
  • 8. Implemented by the object that wants to receive notifications OnNext(T value) Called when a value has been provided OnError(Exception ex) Called in case of an error OnCompleted() When done The contract is OnNext* (OnError|OnCompleted)
  • 9. Implemented by an object which can be observed IDisposable Subscribe( IObserver<T> obs); Called by the observer to subscribe Typical behavior Adds each observer to a List<IObserver<T>> Calls OnXxx() on each listed observer Dispose() called to unsubscribe More composable – no need for Unsubscribe()
  • 10. Typically, you would not implement these interfaces Use helper methods to get Observable<T> Use Subscribe() to act as an Observer<T> Observable.FromEvent() Observable.FromAsyncPattern() EnumerableEx.ToObservable() Enumerable → Observable Observable.Interval Generates an event in an interval
  • 11. Observable.FromXxx lets you create an anonymous observable Subscribe() lets you create an anonymous observer Parameters take An IObserver<T> A combination of Action<T>’s that correspond to OnNext, OnError and OnCompleted
  • 12. New LINQ combinators Amb Time CombineLatest Presence/absence Delay Value changes Repeat Value patterns Utility TakeUntil/TakeWhile SkipUntil/SkipWhile Mirrored in IEnumerable Scan EnumerableEx Timer Using
  • 13. Scan CombineLatest Yields running aggregate Combines each pair of values latest values list = { 1, 2, 3 }; o.Scan((a,b) => a+b) yields 1, 3, 6
  • 14. Merge Zip Collates two streams into Pairwise collection of one items in stream
  • 15. How observables produce values even when not subscribed var timer = new Timer(1000); var hot = Observable.FromEvent( timer, “Elapsed”); Cold observable produces values onl y on subscriptions var cold = Obsevable.Interval( TimeSpan.FromSeconds(1));
  • 16. Rx itself http://bit.ly/reext Rx Team Blog http://blogs.msdn.com/RxTeam/ Lots of Rx videos Rx PowerToys http://rxpowertoys.codeplex.com/ Tracing Time machine scheduler Marble diagram generator (.Net 4) Shameless plug: http://bit.ly/rxrus
  • 17. Questions?

×