04/11/2023 1Eric R Taylor
Reactive Extensions for
.NETPreviously Linq to Events
04/11/2023Eric R Taylor 2
IObserver - Observable
• Comparable to IEnumerable and IEnumerator• Built into .Net 4.0, In the System namespace
04/11/2023Eric R Taylor 3
Push vs. Pull
• Pull – IEnumerableo Gather a set of datao Do something for each item in the set
• Push – IObservableo Decide what you want to do for each itemo React to each item as it is introduced
04/11/2023Eric R Taylor 4
Linq Extensions• Extension methods based on IEnumerable<T>
• Chainable• Filtering – Where• Projection – Select• Paging – Take, Skip• Composition – Join• Rearrange – OrderBy
04/11/2023Eric R Taylor 5
Reactive Extensions• Extension methods based on IObservable<T>
• Chainable• Filtering – Where• Projection – Select• Paging – TakeUntil, SkipUntil• Composition – Merge, Zip, CombineLatest• Time based – Interval, Delay, Throttle, Sample
04/11/2023Eric R Taylor 6
Merge
04/11/2023Eric R Taylor 7
SkipUntil - TakeUntil
green.SkipUntil(blue).TakeUntil(red)
04/11/2023Eric R Taylor 8
Buffer
21 3 4 5 6 7
1 2 3 4 5 6
2 3 4 5 6 7
04/11/2023Eric R Taylor 9
Subscriptions• Joining an IObserver to an IObservable• Returns an IDisposable, Dispose to unsubscribe• Extension methods for Subscribe overrides
04/11/2023Eric R Taylor 10
Scheduler• Most extensions that are time based have
overrides that accept a scheduler.
04/11/2023Eric R Taylor 11
Standard Event Composition
04/11/2023Eric R Taylor 12
Converting Standard Events into Observables
04/11/2023Eric R Taylor 13
Rx Event Composition
04/11/2023Eric R Taylor 14
Rx Event Projection
04/11/2023Eric R Taylor 15
Rx IObservable Chaining
04/11/2023Eric R Taylor 16
Rx Multiple Subscribers
04/11/2023Eric R Taylor 17
Rx Multiple Subscribers