SlideShare une entreprise Scribd logo
1  sur  35
Reactive Extensions for .Net Scott Weinstein Principal Lab49 weblogs.asp.net/sweinstein   / @ScottWeinstein
What is it? The Reactive Extensions for .Net are a new API from MS Dev labs to enable “Linq over Events” Why should I care? Offers a better programming model then Events
Some Concepts
Please sir, can I have some more?
Bid 20, bid 20.2, bid 20.8,…
Pull For pull, data is processed at the leisure of the consumer.  The consumer “pulls” the next item from the producer 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
Push	 For push, data is send via demands of the source.  The producer pushes the data to the consumer. Common examples include: Device measurements such as time light  heat User triggered data such as  Mouse & Keyboard events UI events Sales transactions Asynchronous code
Push & Pull In both scenarios, data moves from the producer to the consumer
Push & Pull in .Net In .Net Pulled data is exposed via common interface pair IEnumerable/IEnumerator There is no other way Foreach and Linq are build on these interfaces 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 its own special way
LINQ LINQprovides 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
DemoSimple Temperature Alerts
Events to Observables Demo
Func and Action and Lambdas Func<int> a; Func<int,int,int> add = (a,b) => a+b; Action<T> t; Action <T,T> tt;
Some (Category) Theory There is a formal basis for the RX Duality, as such, is the assertion that truth is invariant under this operation on statements. In other words, if a statement is true about C, then its dual statement is true about Cop. Also, if a statement is false about C, then its dual has to be false about Cop. Informally, these conditions state that the dual of a statement is formed by reversing arrows and compositions. What this means is that if we can create a Dual of IEnumerable then all of Linq will work over pushed data
Dualizing IEnumerator interface IEnumerator<T>  {     T Current { get; } // but can throw an exception     bool MoveNext();     void Reset(); // not used } Reverse the arrows interface IObserverDraft1<T>  {     SetCurrent(T value); // but need to handle an exception     MoveNext(bool can) ; }
Dualizing IEnumerator (2/2) interface IObserverDraft2<T> {     OnNext(T value);      OnError(Exception ex);     MoveNext(bool can) ; //but called every time! } interface IObserver<T>  {     OnNext(T value);      OnError(Exception ex);     OnCompleted(); // only called once }
Dualizing IEnumerable interface IEnumerable<T>  {     IEnumerator<T> GetEnumerator(); } Reverse the arrows public interface IObservableDraft1<T>  { // But how do I stop observing?     SetObserver(IObserver<T> obs);  }
Dualizing IEnumerable (2/2) interface IObservableDraft2<T>  {     Subscribe(IObserver<T> obs); // can I be more composable?     Unsubscribe(IObserver<T> obs);  } interface IObservable<T>  {     IDisposable Subscribe(IObserver<T> obs); }
Terse functional explanation Enumerable: () –> (() –> Option<T>) FuncEnumerable<T> –> 		Func<Func<Option<T>>> Observable (Option<T> –> ()) –> () FuncObservable<T> –> 			Action<Action<Option<T>>>
Combinators Demo  Implement Where()
Some useful Combinators CombineLatest Do ForkJoin GroupBy Scan HoldUntilChanged Interval Merge ObserveOnDispatcher Sample Throttle Select SelectMany Where Zip
How to create Observables? Create CreateWithDisposable FromAsyncPattern FromEvent Generate ISubject In general, it’s a mistake to create custom implementations of IObservable or IObserver When might it be ok to break this rule?
Streaming OLAP Demo Scan, GroupBy, Where, Zip, Merge, SelectMany
Merge IObservable<T> a IObservable<T> b A.Merge(B) == IObservable<T> ==
Zip IObservable<T> a IObservable<Y> b a.Zip(b, selector) == IObservable<Z> ==
Grouping IObservable<T> IGroupedObservable<TKey, TElement> Key IObservable<IGroupedObservable<Tkey,TElement>> KeyA KeyB KeyC
Hot & Cold Observables (and Enumerables) come in two flavors Hot Values exist outside of subscription Cold Value only exist because of subscription Cold observables can be prone to side-effects ToArray() is one method for making cold Enumerables hot, Replay() and Publish for Observables (and now Enumerables)
Hot and Cold Demo
Code vs. Data RX has an alternate method of representing stream events Interface defines a code-centric view OnNext OnError OnCompleted Notification defines a data-centric view new Notification<T>.OnNext(T next) Where is this useful?
Schedulers RX introduces Schedulers for explicit control  Which thread do subscriptions run on How is time represented ControlSchedulerCurrentThreadScheduler DispatcherSchedulerImmediateScheduler NewThreadSchedulerSynchronizationContextScheduler TaskPoolSchedulerThreadPoolScheduler
Topics not covered Joins Subjects  combine Observability and Enumerablility into a single class.  BehaviorSubject<T> AsyncSubject<T> ReplaySubject<T> Subject<T>
How to get it? Download from the DevLabs: Reactive Extensions for .NET (Rx) site .Net 4 In .Net 4 – IObservable/IObserver are part of the BCL .Net 3.5 SP1 Silverlight 3 Javascript Current license is “go-live” however the API is still evolving
Resources Reactive Extensions for .Net Forums Videos http://weblogs.asp.net/sweinstein
Delayed Expensive Search
DemoAsync webpage download

Contenu connexe

Tendances

Javascript function
Javascript functionJavascript function
Javascript function
LearningTech
 
07 Retrieving Objects
07 Retrieving Objects07 Retrieving Objects
07 Retrieving Objects
Ranjan Kumar
 
C++ Function
C++ FunctionC++ Function
C++ Function
Hajar
 

Tendances (20)

Pointer to function 2
Pointer to function 2Pointer to function 2
Pointer to function 2
 
Erlang Quick Start
Erlang Quick StartErlang Quick Start
Erlang Quick Start
 
Javascript function
Javascript functionJavascript function
Javascript function
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
Lecture4
Lecture4Lecture4
Lecture4
 
Lecture 4, c++(complete reference,herbet sheidt)chapter-14
Lecture 4, c++(complete reference,herbet sheidt)chapter-14Lecture 4, c++(complete reference,herbet sheidt)chapter-14
Lecture 4, c++(complete reference,herbet sheidt)chapter-14
 
This pointer
This pointerThis pointer
This pointer
 
Reactive fsharp
Reactive fsharpReactive fsharp
Reactive fsharp
 
Get Functional on the CLR: Intro to Functional Programming with F#
Get Functional on the CLR: Intro to Functional Programming with F# Get Functional on the CLR: Intro to Functional Programming with F#
Get Functional on the CLR: Intro to Functional Programming with F#
 
Computer Science Programming Assignment Help
Computer Science Programming Assignment HelpComputer Science Programming Assignment Help
Computer Science Programming Assignment Help
 
Data structures and Big O notation
Data structures and Big O notationData structures and Big O notation
Data structures and Big O notation
 
07 Retrieving Objects
07 Retrieving Objects07 Retrieving Objects
07 Retrieving Objects
 
Unit 6 pointers
Unit 6   pointersUnit 6   pointers
Unit 6 pointers
 
Electrical Engineering Exam Help
Electrical Engineering Exam HelpElectrical Engineering Exam Help
Electrical Engineering Exam Help
 
C++ programming function
C++ programming functionC++ programming function
C++ programming function
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015
 
Complexity
ComplexityComplexity
Complexity
 
Docase notation for Haskell
Docase notation for HaskellDocase notation for Haskell
Docase notation for Haskell
 
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
 

En vedette

Distribute Process Knowledge in Adaptive Case management through Mentoring
Distribute Process Knowledge in Adaptive Case management through MentoringDistribute Process Knowledge in Adaptive Case management through Mentoring
Distribute Process Knowledge in Adaptive Case management through Mentoring
AdaPro GmbH
 
scientific management by taylor and fayolism- Administrative management(theor...
scientific management by taylor and fayolism- Administrative management(theor...scientific management by taylor and fayolism- Administrative management(theor...
scientific management by taylor and fayolism- Administrative management(theor...
Reon Zedval
 

En vedette (13)

Distribute Process Knowledge in Adaptive Case management through Mentoring
Distribute Process Knowledge in Adaptive Case management through MentoringDistribute Process Knowledge in Adaptive Case management through Mentoring
Distribute Process Knowledge in Adaptive Case management through Mentoring
 
Adaptive Case Management as a Process of Construction of and Movement in a St...
Adaptive Case Management as a Process of Construction of and Movement in a St...Adaptive Case Management as a Process of Construction of and Movement in a St...
Adaptive Case Management as a Process of Construction of and Movement in a St...
 
Tqm chaos and complexity
Tqm chaos and complexityTqm chaos and complexity
Tqm chaos and complexity
 
Reactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.NetReactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.Net
 
Case Management: Where Rules Meet Process And Content
Case Management: Where Rules Meet Process And ContentCase Management: Where Rules Meet Process And Content
Case Management: Where Rules Meet Process And Content
 
A Case for Declarative Process Modelling - Slides on Adaptive Case Managment ...
A Case for Declarative Process Modelling - Slides on Adaptive Case Managment ...A Case for Declarative Process Modelling - Slides on Adaptive Case Managment ...
A Case for Declarative Process Modelling - Slides on Adaptive Case Managment ...
 
Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015
 
History of Management
History of ManagementHistory of Management
History of Management
 
Adapting to case management
Adapting to case managementAdapting to case management
Adapting to case management
 
Taylorism and Fayolism
Taylorism and FayolismTaylorism and Fayolism
Taylorism and Fayolism
 
scientific management by taylor and fayolism- Administrative management(theor...
scientific management by taylor and fayolism- Administrative management(theor...scientific management by taylor and fayolism- Administrative management(theor...
scientific management by taylor and fayolism- Administrative management(theor...
 
Introduction to BPM
Introduction to BPMIntroduction to BPM
Introduction to BPM
 
Taming The Unpredictable: Real-World Adaptive Case Management
Taming The Unpredictable: Real-World Adaptive Case ManagementTaming The Unpredictable: Real-World Adaptive Case Management
Taming The Unpredictable: Real-World Adaptive Case Management
 

Similaire à Intro to RX

Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
Woody Pewitt
 
Presen 179
Presen 179Presen 179
Presen 179
s1140179
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009
nkaluva
 

Similaire à Intro to RX (20)

Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
 
C++lecture9
C++lecture9C++lecture9
C++lecture9
 
C#, What Is Next?
C#, What Is Next?C#, What Is Next?
C#, What Is Next?
 
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesWindows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
 
MarGotAspect - An AspectC++ code generator for the mARGOt framework
MarGotAspect - An AspectC++ code generator for the mARGOt frameworkMarGotAspect - An AspectC++ code generator for the mARGOt framework
MarGotAspect - An AspectC++ code generator for the mARGOt framework
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
 
Presen 179
Presen 179Presen 179
Presen 179
 
닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기
 
Peaberry - Blending Services And Extensions
Peaberry - Blending Services And ExtensionsPeaberry - Blending Services And Extensions
Peaberry - Blending Services And Extensions
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009
 
Saving lives with rx java
Saving lives with rx javaSaving lives with rx java
Saving lives with rx java
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
First Look at Pointers
First Look at PointersFirst Look at Pointers
First Look at Pointers
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
Von neumann workers
Von neumann workersVon neumann workers
Von neumann workers
 
overloading in C++
overloading in C++overloading in C++
overloading in C++
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Intro to RX

  • 1. Reactive Extensions for .Net Scott Weinstein Principal Lab49 weblogs.asp.net/sweinstein / @ScottWeinstein
  • 2. What is it? The Reactive Extensions for .Net are a new API from MS Dev labs to enable “Linq over Events” Why should I care? Offers a better programming model then Events
  • 4. Please sir, can I have some more?
  • 5. Bid 20, bid 20.2, bid 20.8,…
  • 6. Pull For pull, data is processed at the leisure of the consumer. The consumer “pulls” the next item from the producer 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
  • 7. Push For push, data is send via demands of the source. The producer pushes the data to the consumer. Common examples include: Device measurements such as time light heat User triggered data such as Mouse & Keyboard events UI events Sales transactions Asynchronous code
  • 8. Push & Pull In both scenarios, data moves from the producer to the consumer
  • 9. Push & Pull in .Net In .Net Pulled data is exposed via common interface pair IEnumerable/IEnumerator There is no other way Foreach and Linq are build on these interfaces 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 its own special way
  • 10. LINQ LINQprovides 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
  • 13. Func and Action and Lambdas Func<int> a; Func<int,int,int> add = (a,b) => a+b; Action<T> t; Action <T,T> tt;
  • 14. Some (Category) Theory There is a formal basis for the RX Duality, as such, is the assertion that truth is invariant under this operation on statements. In other words, if a statement is true about C, then its dual statement is true about Cop. Also, if a statement is false about C, then its dual has to be false about Cop. Informally, these conditions state that the dual of a statement is formed by reversing arrows and compositions. What this means is that if we can create a Dual of IEnumerable then all of Linq will work over pushed data
  • 15. Dualizing IEnumerator interface IEnumerator<T> { T Current { get; } // but can throw an exception bool MoveNext(); void Reset(); // not used } Reverse the arrows interface IObserverDraft1<T> { SetCurrent(T value); // but need to handle an exception MoveNext(bool can) ; }
  • 16. Dualizing IEnumerator (2/2) interface IObserverDraft2<T> { OnNext(T value); OnError(Exception ex); MoveNext(bool can) ; //but called every time! } interface IObserver<T> { OnNext(T value); OnError(Exception ex); OnCompleted(); // only called once }
  • 17. Dualizing IEnumerable interface IEnumerable<T> { IEnumerator<T> GetEnumerator(); } Reverse the arrows public interface IObservableDraft1<T> { // But how do I stop observing? SetObserver(IObserver<T> obs); }
  • 18. Dualizing IEnumerable (2/2) interface IObservableDraft2<T> { Subscribe(IObserver<T> obs); // can I be more composable? Unsubscribe(IObserver<T> obs); } interface IObservable<T> { IDisposable Subscribe(IObserver<T> obs); }
  • 19. Terse functional explanation Enumerable: () –> (() –> Option<T>) FuncEnumerable<T> –> Func<Func<Option<T>>> Observable (Option<T> –> ()) –> () FuncObservable<T> –> Action<Action<Option<T>>>
  • 20. Combinators Demo Implement Where()
  • 21. Some useful Combinators CombineLatest Do ForkJoin GroupBy Scan HoldUntilChanged Interval Merge ObserveOnDispatcher Sample Throttle Select SelectMany Where Zip
  • 22. How to create Observables? Create CreateWithDisposable FromAsyncPattern FromEvent Generate ISubject In general, it’s a mistake to create custom implementations of IObservable or IObserver When might it be ok to break this rule?
  • 23. Streaming OLAP Demo Scan, GroupBy, Where, Zip, Merge, SelectMany
  • 24. Merge IObservable<T> a IObservable<T> b A.Merge(B) == IObservable<T> ==
  • 25. Zip IObservable<T> a IObservable<Y> b a.Zip(b, selector) == IObservable<Z> ==
  • 26. Grouping IObservable<T> IGroupedObservable<TKey, TElement> Key IObservable<IGroupedObservable<Tkey,TElement>> KeyA KeyB KeyC
  • 27. Hot & Cold Observables (and Enumerables) come in two flavors Hot Values exist outside of subscription Cold Value only exist because of subscription Cold observables can be prone to side-effects ToArray() is one method for making cold Enumerables hot, Replay() and Publish for Observables (and now Enumerables)
  • 28. Hot and Cold Demo
  • 29. Code vs. Data RX has an alternate method of representing stream events Interface defines a code-centric view OnNext OnError OnCompleted Notification defines a data-centric view new Notification<T>.OnNext(T next) Where is this useful?
  • 30. Schedulers RX introduces Schedulers for explicit control Which thread do subscriptions run on How is time represented ControlSchedulerCurrentThreadScheduler DispatcherSchedulerImmediateScheduler NewThreadSchedulerSynchronizationContextScheduler TaskPoolSchedulerThreadPoolScheduler
  • 31. Topics not covered Joins Subjects combine Observability and Enumerablility into a single class. BehaviorSubject<T> AsyncSubject<T> ReplaySubject<T> Subject<T>
  • 32. How to get it? Download from the DevLabs: Reactive Extensions for .NET (Rx) site .Net 4 In .Net 4 – IObservable/IObserver are part of the BCL .Net 3.5 SP1 Silverlight 3 Javascript Current license is “go-live” however the API is still evolving
  • 33. Resources Reactive Extensions for .Net Forums Videos http://weblogs.asp.net/sweinstein