• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Dokkio Sidebar (from the makers of PBworks) is a Chrome extension that eliminates the need for endless browser tabs. You can search all your online stuff without any extra effort. And Sidebar was #1 on Product Hunt! Check out what people are saying by clicking here.


Reactive Extensions

Page history last edited by Chris Bilson 11 years, 4 months ago




  • nuget i Rx-All 
  • generators: Observable.Create<int>(...)
  • adapters:
    • Observable.FromEvent<MouseEventArgs>(...)
    • .FromEventPattern<MouseEventArgs>(frm, "MouseMove") <- uses reflection to find the event
  • composition
    • frm.MouseMove += (_, args) =>  { if (this) ... else if (that) ... } <- not composable
    • Observable.FromEventPattern<>(...).Select(...) <-  specific events, logic not in action, actions composable
    • crossing streams: Observable.___<>(...).SelectMany(evt => ...) 
  • schedulers
    • Observable.Timer(5.Seconds()) <- fires one event in 5 seconds
    • Which timer? Up to you. Scheduler abstraction. 
      • context + policy + clock
      • distrib. process, you might use remote clock
      • IScheduler <- mostly don't need to worry about. Use defaults: Observable.Range(1, 10, Scheduler.ThreadPool)
      • Scheduler.Immediate, Scheduler.Dispatcher.... 
      • Some of the schedulers are in different assemblies (if they depend on winforms, or whatever) for portability 
      • TestScheduler (see below) 
  • testing
    • time problem
      • want a virtual clock
      • scheduler = new TestScheduler()
      • scheduler.CreateObservable(OnNext(300, "wes"), OnNext(400, "ryan"), OnCompleted(500))
      • results = scheduler.Run(...)
      • results.AssertEqual(...) 
  • debugging
    • Use .Do to cause side effects (like Console.WriteLine) that you can observe to figure out what's going on 
  • Other stuff
    • .DistinctUntilChanged can de-dup an event stream
    • .Timestamp makes T into Timestamped<T> which 
    • Throttle: A----B--200ms----C -> A gets cancelled because B happened within throttle period 
  • Challenges
    • Challenge in learning Rx: there are a lot of operators 
  • Path Forward
    • Already on the Win7 Phone ROM
    • Unstable releases every 3 weeks-ish right now 
    • Stable releases: not as often, but supported, documentation, etc. .NET 4.0+, Silverlight 5, Win7 Phone
    • Binaries and doc comments are redistributable

Comments (0)

You don't have permission to comment on this page.