A class that implements two different IObservables?

I have a class with two events, name them StatusChanged and ValueChanged . I am interested in exposing these "streams" as IObservable . Does IObservable<Status> and IObservable<Value> in the same class? Could this cause me (or users of my class) grief?

+2
c # system.reactive
Jan 28 '13 at 10:36
source share
1 answer

Implementing a covariant interface for different types is a really bad idea. See what happens if you apply the class to the IObservable<object> , which is now ambiguous.

I would prefer to have two properties: IObservable<Status> StatusObservable{get{...}} and IObservable<Value> ValueObservable{get{...}} . Simple, clean and reflects the two events that your class offers.

+5
Jan 28 '13 at 11:11
source share



All Articles