private void PrepareObservables() { this.WhenAnyValue(e => e.Username, p => p.Password, (emailAddress, password) => (!string.IsNullOrEmpty(emailAddress)) && !string.IsNullOrEmpty(password) && password.Length > 5) .ToProperty(this, v => v.IsValid, out _isValid); var canExecuteLogin = this.WhenAnyValue(x => x.IsLoading, x => x.IsValid, (isLoading, IsValid) => !isLoading && IsValid); LoginCommand = ReactiveCommand.CreateFromTask( async execute => { var accessDTO = new Ref <AccessDTO>(); await RunSafe(ExecuteApi(LoginApi.GetToken(new UserInfoDTO { AccessKey = Password, UserId = Username }), accessDTO)); if (accessDTO.Value.Authenticated) { await SecurityData.SaveUser(accessDTO.Value); HostScreen.Router.Navigate.Execute(new IntentionsList()).Subscribe(); } }, canExecuteLogin); this.WhenAnyObservable(x => x.LoginCommand.IsExecuting) .StartWith(false) .ToProperty(this, x => x.IsLoading, out _isLoading); }