c# reactive extensionBASICALLSDSDSDSDvar

http://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fteched%2f2012%2feu%2fDEV413.pptx

Basics

  1. Events can be treated like Collection. Both are stream of items of a particular type
  2. Every Collection needs to implement IEnumerable
  3. Rx is a layer on top of disparate event (generated by disparate sources like cloud, svc, hardware) that can be consolidated into single collection
  4. So basically our code is Observer subscribing to a Rx Observable (collection of events)
  5. Now whenever a new event occurs in the world, Obbserver’s callback is called..so this is non blocking async action…
  6. IObservable can raise Next () when next event occurs, or Error() or complete() like Pub Sub Model
  7. Rx vs Events:
    1. Events aren’t 1st class, so can’t pass them around, while IObservable<T> is Type
    2. have to be managed individually, while Observable has dispose to dispose off all event handlers
    3. Observable implements iEnumerable and so can be enumerated or written LYNQ query on..
  8. BASICALLY RX OBSERVABLE<T> IS COLLECTION OF EVENTS, AND AN ABSTRACTION LAYER OVER EVENTS TO MANAGE THEM TOGETHER
  9. rx can be used from rx-main nuget .it has 4 dlls
  10. tO CREATE OBSERVABLE FROM NORMAL C# EVENTS: var observable = Observable.FromEventPattern(EVENT);
  11. then say observable.subscribe()
  12. But to do lynq, say: var observable = from _ in Observable.FromEventPattern(textbox) select  textbox.text. Throttle()…ie you can use RX features on this iObservable stream..
  13. Now if another action needs to be performed on this stream, keep it ready:
    1. var result = from observalbe select …..
    2. Then subs to : result.subscribe(observable)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s