I have recently started learning reactive extensions and not an expert on Rx. However, I am changing a previously written application into Reactive UI. But, when I wanted to change a RelayCommand to ReactiveCommand<Unit, Unit>, I faced this error:
System.NotSupportedException: 'Index expressions are only supported with constants. My RelayCommand was defined as bellow:
DownloadCmd = new RelayCommand(async x=> await DownloadSubtitle(), CheckYoutubeLink);
I changed it with a Reactive Command as follow:
var can = this.WhenAnyObservable(x=>Observable.Return(x.CheckYoutubeLink()));
DownloadCmd = ReactiveCommand.CreateFromTask(_ => DownloadSubtitle(),can);
Unfortunately, it does not work. In other words, my question is how to use a function (Func) for "canExecute" parameters or something that behaves like functions. By the way, I do not prefer to use Properties instead of functions since I have to write many properties for my commands. I have checked this link: ReactiveUI: Using CanExecute with a ReactiveCommand however, it cannot help me a lot.
CheckYoutubeLink
is currently implemented and how and when you raise theCanExecuteChanged
method of yourRelayCommand
? – mm8