2017-09-11 50 views
0

我使用無UI 7如何訂閱一個ReactiveCommand的結果

我有以下功指令:

public ReactiveCommand SignupCommand { get; protected set; } 

SignupCommand = ReactiveCommand.CreateFromObservable<ParentEntity>(RegisterTask); 

SignupCommand.IsExecuting.Subscribe((isLoading) => { 
    if (isLoading){ 
         _userDialogs.ShowLoading(AppResources.Signup_CreatingAccount, MaskType.Black); 
         } 
         else 
         { 
          _userDialogs.HideLoading(); 
         } 
        }); 

SignupCommand.ThrownExceptions.Subscribe((ex) => 
    { 
         Debug.WriteLine(String.Format("Exception: {0}", ex.ToString())); 
         _mvxMessenger.Publish(new ExceptionOcurredMessage(this, ex)); 
        }); 

當我嘗試訂閱訂閱功指令結果,此方法不再可用。有SubscribeToExpressionChain方法,我不太明白如何使用。

我應該使用ReactiveCommandBase類嗎?

在此先感謝。

回答

1

SubscribeSystem命名空間中的擴展方法。 ReactiveCommand<TSomething,T> implements IObservable<T>。你需要添加一個導入/使用語句嗎?

試試這個:System.ObservableExtensions.Subscribe(SignupCommand, a => { });。如果編譯,你只是缺少一個使用。