Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reactive Extension to.NET.  Hollywood principle  Allows you to provide delegates to be called by another object.

Similar presentations


Presentation on theme: "Reactive Extension to.NET.  Hollywood principle  Allows you to provide delegates to be called by another object."— Presentation transcript:

1 Reactive Extension to.NET

2

3  Hollywood principle  Allows you to provide delegates to be called by another object

4  Plenty of extension methods  Encourages monadic programming

5 .NET 3.5 .NET 4.0  Silverlight 3  Silverlight 4  Windows Phone  JavaScript!

6  Composable  Transformative  Declarative  Extensible  Unitive  Integrated

7 Why would you use Rx and why do you care?

8  Data being pushed  Async requests

9  WPF or Silverlight GUIs  AJAX

10  Concatenation Concat, OnError/Catch, Retry  Merging streams Merge, Zip, SelectMany, Amb, CombineLatest, ForkJoin  Grouping stream data GroupBy, Window, Buffer, GroupJoin

11  Observer pattern is ~15years old  Java has already got the interface .NET has events

12  The Java interface is bloated .NET events are pretty silly.

13

14  IObserver  IObservable  ISubject  Factory Methods  Extension Methods  Scheduling and Concurrency

15 namespace System { public interface IObserver { void OnNext(T value); void OnError(Exception error); void OnCompleted(); }

16 namespace System { public interface IObservable { IDisposable Subscribe( IObserver observer); }

17 namespace System.Collections.Generic { public interface ISubject : IObserver, IObservable { } public interface ISubject : ISubject, IObserver, IObservable { } }

18  Generate / GenerateWithTime  Range / Interval  Create / CreateWithDisposable  Empty / Return / Never / Throw  FromAsyncPattern / FromEvent

19  Aggregates Aggregate, Sum, Count, Max, Min, First, Last...  Filter Where, Skip, Take, First, Last  Grouping Window, Buffer, GroupJoin  Composition Concat, Merge,  Flow control Amb, Case, If, While

20 namespace System.Concurrency { public interface IScheduler { DateTimeOffset Now { get; } IDisposable Schedule(Action action); IDisposable Schedule( Action action, TimeSpan dueTime); }

21 namespace System.Concurrency { public static class Scheduler { public static ImmediateScheduler Immediate; public static CurrentThreadScheduler CurrentThread; public static ThreadPoolScheduler ThreadPool; public static NewThreadScheduler NewThread; public static TaskPoolScheduler TaskPool; public static DispatcherScheduler Dispatcher; } //EventLoopScheduler //TestScheduler //ControlScheduler

22  WPF/Silverlight developers Allowing Rx to schedule work on to the ThreadPool/TaskPool Return results on the dispatcher Easily testable (without pushing a Dispatcher frame!)  Serverside teams working on streaming data (finance, instrumentation) Compose many feeds Easily testable IQbservable may allow you to send the declaration to the server to process (GPUs/FSharp expressions)

23

24  Use marble diagrams (esp first 12 months)  Honour the Completion contracts  Apply scheduling only at the end consumer  Avoid breaking the monad (.First() etc)  Avoid Side effects (or be explicit via.Do())  Favour composition over creating new operators  Avoid use of Subjects, favour factories. Google “Rx Design Guidelines”

25  Mitch Wheat  Erik Meijer’s team at Microsoft  Lab49

26  Data Developer Center (for the download or get via Nuget)  LeeCampbell.blogspot.com  EnumerateThis.com (or just talk to James)  Rx Forums (which is the same as talking to James)


Download ppt "Reactive Extension to.NET.  Hollywood principle  Allows you to provide delegates to be called by another object."

Similar presentations


Ads by Google