I'm trying to avoid an update to a property if another property is changing. So I've come up with the following (in my ViewModel):
this.WhenAnyObservable(
x => x.WhenAnyValue( y => y.Asset.CurrentValuation ),
x => x.Changing,
(currentValuation, changing) => changing.PropertyName != "CurrentValuationCalculated"
)
However, ReactiveUI throws the following error inside ExpressionRewriter.VisitMethodCall
:
throw new NotSupportedException("Index expressions are only supported with constants.")
If I remove the WhenAnyValue
line, it works. So I'm assuming it's something to do with the expression inside WhenAnyValue
?
Without delving into what the ExpressionRewriter
code actually does, what is it complaining about? Have I made some sort of simple error?
Update
So I've entered this instead:
this.WhenAnyObservable(
x => x.Asset.CurrentValuation,
x => x.Changing,
( currentValuation, changing ) => changing.PropertyName != "CurrentValuationCalculated"
)
However, the compiler complains about x.Asset.CurrentValuation
and says:
Cannot implicitly convert type 'decimal?' to 'System.IObservable<ReactiveUI.IReactivePropertyChangedEventArgs<ReactiveUI.IReactiveObject>>'