public RatingViewModel( ITimeService timeService, IRatingService ratingService, IAnalyticsService analyticsService, IOnboardingStorage onboardingStorage, INavigationService navigationService, ISchedulerProvider schedulerProvider, IRxActionFactory rxActionFactory) : base(navigationService) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(ratingService, nameof(ratingService)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.timeService = timeService; this.ratingService = ratingService; this.analyticsService = analyticsService; this.onboardingStorage = onboardingStorage; this.schedulerProvider = schedulerProvider; Impression = impressionSubject.AsDriver(this.schedulerProvider); IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsDriver(this.schedulerProvider); HideRatingView = hideRatingView.AsDriver(this.schedulerProvider); PerformMainAction = rxActionFactory.FromAsync(performMainAction); }
public SendFeedbackViewModel( INavigationService navigationService, IInteractorFactory interactorFactory, IDialogService dialogService, ISchedulerProvider schedulerProvider, IRxActionFactory rxActionFactory) { Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(dialogService, nameof(dialogService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.dialogService = dialogService; this.interactorFactory = interactorFactory; this.navigationService = navigationService; IsFeedbackEmpty = isEmptyObservable.DistinctUntilChanged().AsDriver(schedulerProvider); SendEnabled = sendingIsEnabledObservable.DistinctUntilChanged().AsDriver(schedulerProvider); Close = rxActionFactory.FromObservable(cancel); DismissError = rxActionFactory.FromAction(dismissError); Send = rxActionFactory.FromObservable(sendFeedback, sendingIsEnabledObservable); IsLoading = isLoadingSubject.AsDriver(false, schedulerProvider); Error = currentErrorSubject.AsDriver(default(Exception), schedulerProvider); }
public SendFeedbackViewModel( IMvxNavigationService navigationService, IInteractorFactory interactorFactory, IDialogService dialogService, ISchedulerProvider schedulerProvider) { Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(dialogService, nameof(dialogService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); this.dialogService = dialogService; this.interactorFactory = interactorFactory; this.navigationService = navigationService; IsFeedbackEmpty = isEmptyObservable.DistinctUntilChanged().AsDriver(schedulerProvider); SendEnabled = sendingIsEnabledObservable.DistinctUntilChanged().AsDriver(schedulerProvider); CloseButtonTapped = new UIAction(cancel); ErrorViewTapped = new UIAction(dismissError); SendButtonTapped = new UIAction(sendFeedback, sendingIsEnabledObservable); ErrorViewVisible = errorViewVisibleSubject.AsDriver(true, schedulerProvider); IsLoading = isLoadingSubject.AsDriver(false, schedulerProvider); }
public RatingViewModel( ITimeService timeService, ITogglDataSource dataSource, IRatingService ratingService, IAnalyticsService analyticsService, IOnboardingStorage onboardingStorage, IMvxNavigationService navigationService, ISchedulerProvider schedulerProvider, IRxActionFactory rxActionFactory) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(ratingService, nameof(ratingService)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.dataSource = dataSource; this.timeService = timeService; this.ratingService = ratingService; this.analyticsService = analyticsService; this.onboardingStorage = onboardingStorage; this.navigationService = navigationService; this.schedulerProvider = schedulerProvider; this.rxActionFactory = rxActionFactory; Impression = impressionSubject.AsDriver(this.schedulerProvider); CallToActionTitle = impressionSubject .Select(callToActionTitle) .AsDriver(this.schedulerProvider); CallToActionDescription = impressionSubject .Select(callToActionDescription) .AsDriver(this.schedulerProvider); CallToActionButtonTitle = impressionSubject .Select(callToActionButtonTitle) .AsDriver(this.schedulerProvider); IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsDriver(this.schedulerProvider); HideRatingView = hideRatingView.AsDriver(this.schedulerProvider); PerformMainAction = rxActionFactory.FromAsync(performMainAction); }
public ForgotPasswordViewModel( ITimeService timeService, IUserAccessManager userAccessManager, IAnalyticsService analyticsService, ISchedulerProvider schedulerProvider, INavigationService navigationService, IRxActionFactory rxActionFactory) : base(navigationService) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.timeService = timeService; this.userAccessManager = userAccessManager; this.analyticsService = analyticsService; this.rxActionFactory = rxActionFactory; Reset = rxActionFactory.FromObservable(reset); PasswordResetWithInvalidEmail = passwordResetWithInvalidEmailSubject.AsDriver(schedulerProvider); var resetActionStartedObservable = Reset .Executing .Where(executing => executing) .Select(_ => (Exception)null); ErrorMessage = Reset.Errors .Merge(resetActionStartedObservable) .Select(toErrorString) .StartWith("") .DistinctUntilChanged(); PasswordResetSuccessful = Reset.Elements .Select(_ => true) .StartWith(false) .AsDriver(schedulerProvider); EmailValid = Email .Select(email => email.IsValid) .DistinctUntilChanged(); }
public RatingViewModel( ITimeService timeService, ITogglDataSource dataSource, IRatingService ratingService, IAnalyticsService analyticsService, IOnboardingStorage onboardingStorage, IMvxNavigationService navigationService, ISchedulerProvider schedulerProvider) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(ratingService, nameof(ratingService)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); this.dataSource = dataSource; this.timeService = timeService; this.ratingService = ratingService; this.analyticsService = analyticsService; this.onboardingStorage = onboardingStorage; this.navigationService = navigationService; this.schedulerProvider = schedulerProvider; Impression = impressionSubject.AsDriver(this.schedulerProvider); CtaTitle = impressionSubject .Select(ctaTitle) .AsDriver(this.schedulerProvider); CtaDescription = impressionSubject .Select(ctaDescription) .AsDriver(this.schedulerProvider); CtaButtonTitle = impressionSubject .Select(ctaButtonTitle) .AsDriver(this.schedulerProvider); IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsDriver(this.schedulerProvider); }
public SendFeedbackViewModel( IMvxNavigationService navigationService, IInteractorFactory interactorFactory, IDialogService dialogService, ISchedulerProvider schedulerProvider ) { Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(dialogService, nameof(dialogService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); IsFeedbackEmpty = FeedbackText .Select(text => string.IsNullOrEmpty(text)) .DistinctUntilChanged() .StartWith(true) .AsDriver(schedulerProvider); SendEnabled = Observable.CombineLatest( IsFeedbackEmpty, isLoading.AsObservable(), (isEmpty, isLoading) => !isEmpty && !isLoading ) .AsDriver(schedulerProvider); CloseButtonTapped .WithLatestFrom(IsFeedbackEmpty, (_, isEmpty) => isEmpty) .SelectMany(isEmpty => { if (isEmpty) { return(Observable.Return(true)); } return(dialogService.ConfirmDestructiveAction(ActionType.DiscardFeedback)); }) .Where(shouldDiscard => shouldDiscard) .Do(_ => { navigationService.Close(this, false); }) .Subscribe() .DisposedBy(disposeBag); ErrorViewTapped .Do(e => errorViewVisible.OnNext(false)) .Subscribe() .DisposedBy(disposeBag); SendButtonTapped .WithLatestFrom(FeedbackText, (_, text) => text) .Do(_ => { isLoading.OnNext(true); errorViewVisible.OnNext(false); }) .SelectMany(text => interactorFactory .SendFeedback(text) .Execute() .Materialize() ) .Do(notification => { isLoading.OnNext(false); switch (notification.Kind) { case NotificationKind.OnError: errorViewVisible.OnNext(true); break; default: navigationService.Close(this, true); break; } }) .Subscribe() .DisposedBy(disposeBag); ErrorViewVisible = errorViewVisible.AsDriver(true, schedulerProvider); IsLoading = isLoading.AsDriver(false, schedulerProvider); }