public TwitterTestViewModel(ITwitterService service = null) { _service = service ?? Resolver.Resolve <ITwitterService>(); this.WhenActivated(registerDisposable => { var canLogoutOrGetProfile = _service.CurrentAccount.AsObservable().Select(account => null != account); var canAuthorize = _service .ServiceReadySub .AsObservable() .Select(authenticator => null != authenticator) .CombineLatest(canLogoutOrGetProfile, (arg1, arg2) => arg1 && !arg2); LogInCommand = ReactiveCommand.CreateAsyncObservable(canAuthorize, args => Observable.Start(() => _service.Authorize())); LogOutCommand = ReactiveCommand.CreateAsyncObservable(canLogoutOrGetProfile, args => Observable.Start(async() => await _service.Logout())); GetProfileCommand = ReactiveCommand.CreateAsyncObservable(canLogoutOrGetProfile, args => Observable.Start(() => { IsLoaderShowing = true; _service .GetUserData() .ObserveOnUI() .Catch(ex => { IsLoaderShowing = false; Error = ex.Message; }).SubscribeOnce(data => { UserData = data; IsLoaderShowing = false; }); })); }); }