Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Charanke.ViewModels.LoginPageViewModel"/> class.
        /// </summary>
        public LoginPageViewModel()
        {
            _firebaseModel = new FirebaseModel();

            Email = ReactiveProperty.FromObject(
                _firebaseModel,
                x => x.Email);

            Password = ReactiveProperty.FromObject(
                _firebaseModel,
                x => x.Password);

            AuthMessage = _firebaseModel.ObserveProperty(m => m.AuthMessage)
                          .ToReadOnlyReactiveProperty();

            SendSignInByEmailAndPassword = Email.ObserveHasErrors.CombineLatest(
                Password.ObserveHasErrors, (x, y) => !x && !y)
                                           .ToReactiveCommand();

            SendSignUpByEmailAndPassword = Email.ObserveHasErrors.CombineLatest(
                Password.ObserveHasErrors, (x, y) => !x && !y)
                                           .ToReactiveCommand();

            SendSignInByEmailAndPassword.Subscribe(
                async _ => await this.SignInByEmailAndPasswordAction());

            SendSignUpByEmailAndPassword.Subscribe(
                async _ => await this.SignUpByEmailAndPasswordAction());
        }