I have a class with two events, call them StatusChanged and ValueChanged. I’m wondering about exposing these ‘streams’ as IObservable. Is implementing IObservable<Status> and IObservable<Value> on the same class ‘bad’? Is it likely to cause me (or users of my class) grief?
I have a class with two events, call them StatusChanged and ValueChanged . I’m
Share
Implementing a covariant interface for different types is a really bad idea. Consider what happens if you cast the class to
IObservable<object>, which is now ambiguous.I’d rather have two properties
IObservable<Status> StatusObservable{get{...}}andIObservable<Value> ValueObservable{get{...}}. Simple, clean and it mirrors the two events your class offers.