public ActionCommand(Action execute, IObservableReadOnlyValue <bool> canExecute) { _execute = execute ?? throw new ArgumentNullException(nameof(execute)); CanExecute = canExecute ?? ObservableValue.Create(true); _canExecuteSubscription = canExecute?.Subscribe(x => CanExecuteChanged?.Invoke(this, EventArgs.Empty)); }
public AsyncActionCommand(Func <CancellationToken, Task> executeAsync, IObservableReadOnlyValue <bool> canExecute) { _executeAsync = executeAsync ?? throw new ArgumentNullException(nameof(executeAsync)); CanExecute = canExecute ?? ObservableValue.Create(true); _canExecuteSubscription = canExecute?.Subscribe(x => CanExecuteChanged?.Invoke(this, EventArgs.Empty)); }