Checked back with my old questions, I was looking for something like this solution:
this.WhenAny(x => x.Item, x => x.GetValue()).OfType<IInterface>()
.Select(x => x.WhenAny(y => y.PropertyFromInterface, y => y.Value).Switch()
.Subscribe(DoSomethingWith);
The missing link for me was the .Switch method.
Additionally, I wanted the observable to not do anything if the property is NOT of the needed type:
this.WhenAny(x => x.Item, x => x.Value as IInterface)
.Select(x => x == null ?
Observable.Empty :
x.WhenAny(y => y.PropertyFromInterface, y => y.Value)
.Switch().Subscribe(DoSomethingWith);
(e.g. When I set this.Item
to an instance of IInterface
, I wanted DoSomethingWith
to listen to changes to that instance's PropertyFromInterface
, and when this.Item
gets set to something different, the observable should not continue to fire until this.Item
is an instance of IInterface
again.)