/// <summary> /// コンストラクタ。 /// </summary> /// <param name="command">非同期コマンド。</param> private AsyncCommandHolderBase(AsyncReactiveCommand <TParameter> command) { if (command == null) { return; } // 戻り値の通知先 // 同値でも通知されるように DistinctUntilChanged を外す var result = new ReactiveProperty <TResult>( default(TResult), ReactivePropertyMode.RaiseLatestValueOnSubscribe) .AddTo(this.CompositeDisposable); var busy = new ReactiveProperty <bool>(false).AddTo(this.CompositeDisposable); command .Subscribe( async p => { busy.Value = true; try { result.Value = await this.Execute(this.ConvertParameter(p)); } finally { busy.Value = false; } }) .AddTo(this.CompositeDisposable); this.Command = command; this.CanExecute = command .CanExecuteToReadOnlyReactiveProperty() .AddTo(this.CompositeDisposable); this.IsBusy = busy; this.Result = result; }