0

I'm sure I've missed something or backed myself into some strange frustrated corner, but here is what I'm trying to do.

I have a WPF application, using Unity as IoC. I have a number of services that have an interface. I deal with my services via the interfaces so the services can be swapped out easily or so that I can offer a choice to the end-user. All standard interface programming stuff.

In reality, all my services implement ReactiveObject. I am now wanting to do some command handling stuff and am trying to get the CanExecute behaviour working.

My basic problem is I cannot use WhenAny unless I cast the interface to a physical implementation (thus get the full type hierarchy for compilation, which can see WhenAny). However, this cast violates interfaces and means I lose the ability to swap out implementations.

Is there a ReactiveUI interface that exposes WhenAny etc that I could derive my service interfaces from and thus be able to use the great features of ReactiveUI whilst remaining non-type specific?

Patrick
  • 17,669
  • 6
  • 70
  • 85
Simon
  • 118
  • 1
  • 3
  • There's no need to add personal greetings in the questions. Your contact card is displayed at the bottom right of all your questions. – Patrick Mar 24 '13 at 17:38
  • Sorry, it's the first time I asked a question and have never noticed no-one else does it. :) – Simon Mar 24 '13 at 17:41

1 Answers1

0

Why can't you use WhenAny on an instance that is an interface? As of ReactiveUI 4.x, WhenAny should be on every object.

If you're still using 3.x, you can write your interfaces like this:

interface ICoolInterface : IReactiveNotifyPropertyChanged
{
    /* ... */
}
Ana Betts
  • 73,868
  • 16
  • 141
  • 209
  • Ah ok, so if my service interface inherits from that IReactive interface, I should get the WhenAny etc extensions? I shall give this a try later and confirm. – Simon Mar 25 '13 at 15:58
  • Worked a treat. I will upgrade to the latest version though to grab fixes and features. – Simon Mar 25 '13 at 17:11