public StageEventListRootPageViewModel(INavigationService navigationService, IFilterGroupingStageEvent eventUsecase) { _eventUsecase = eventUsecase; Title.AddTo(this.Disposable); SelectedSegment.AddTo(this.Disposable); FavStateObservable.AddTo(this.Disposable); SelectedSegment.Subscribe(selectedSegment => { _eventUsecase.UpdateFilterConditions(SelectedSegment.Value, FavStateObservable.Value, PlaceId); }).AddTo(this.Disposable); FavButtonClickCommand = new DelegateCommand(() => { FavStateObservable.Value = !FavStateObservable.Value; _eventUsecase.UpdateFilterConditions(SelectedSegment.Value, FavStateObservable.Value, PlaceId); }); IconSource = FavStateObservable.Select((isFavActive) => { return($@"ion_ios_heart{(isFavActive ? "" : "_outline")}"); }).ToReadOnlyReactiveProperty("ion_ios_heart").AddTo(this.Disposable); Plannings = _eventUsecase.Plannings.ToReadOnlyReactiveCollection().AddTo(this.Disposable); SelectedItemCommand = new AsyncReactiveCommand <IPlanning>(); SelectedItemCommand.Subscribe(async(item) => { await navigationService.NavigateAsync( nameof(PlanningDetailPageViewModel).GetViewNameFromRule(), PlanningDetailPageViewModel.GetNavigationParameter(item.Id, item.PlanningType)); }).AddTo(this.Disposable); }
public MainWindowViewModel() { Button1Command = new AsyncReactiveCommand().WithSubscribe(Button1Processing).AddTo(Disposable); Button2Command = IsButtonEnable.ToAsyncReactiveCommand().WithSubscribe(Button2Processing).AddTo(Disposable); Button3Command = IsButtonEnable.ToAsyncReactiveCommand().WithSubscribe(Button3Processing).AddTo(Disposable); ClosedCommand.Subscribe(Close).AddTo(Disposable); }
public UpComingMoviePageViewModelBase(INavigationService navigationService, IMovieService movieService, IDialogService dialogService) : base(navigationService, dialogService) { _movieService = movieService; Keyword = new ReactiveProperty <string>(); IsExistText.Value = false; SearchMovieCommand = new AsyncReactiveCommand(); SearchMovieCommand.Subscribe(async() => { PullData(); }); SelectedItemCommand = new AsyncReactiveCommand <Movie>(); SelectedItemCommand.Subscribe(async movie => { var param = new NavigationParameters { { "Id", movie.Id } }; await _navigationService.NavigateAsync(nameof(MovieDetailPage), param); }); ClearSearchCommand = new AsyncReactiveCommand(); ClearSearchCommand.Subscribe(async() => { MovieList = new List <Movie>(); Keyword.Value = null; }); }
public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IAuthService authService) : base(navigationService) { _pageDialogService = pageDialogService; _authService = authService; Title = "Main Page"; _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) => { _isSignedIn.Value = auth.CurrentUser != null; }); ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand(); SignUpCommand.Subscribe(SignUp); SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword); SignInWithGoogleCommand.Subscribe(SignInWithGoogle); SignInWithTwitterCommand.Subscribe(SignInWithTwitter); SignInWithFacebookCommand.Subscribe(SignInWithFacebook); SignInWithGitHubCommand.Subscribe(SignInWithGitHub); SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber); SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously); ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>()); }
/// <summary> /// コンストラクタ /// </summary> public ViewModel() { var options = _Model.GetCommandlineOptions(); InDirPath = new ReactiveProperty <string>(options.InputDirectory); OutFilePath = new ReactiveProperty <string>(options.OutputFilePath); Langages = new ReactiveCollection <LangComboboxItem>(); SelectedLangage = new ReactiveProperty <LangComboboxItem?>(); MaxSteps = new ReactiveProperty <int>(1); CurrentStep = new ReactiveProperty <int>(0); CanOperation = new ReactiveProperty <bool>(true); // 操作可能かつ入力項目に不備がない場合に true にする var canExport = new[] { CanOperation, InDirPath.Select(p => !string.IsNullOrEmpty(p)), OutFilePath.Select(p => !string.IsNullOrEmpty(p)), SelectedLangage.Select(l => l != null), }.CombineLatestValuesAreAllTrue(); SelectInDirCommand = new ReactiveCommand(CanOperation).WithSubscribe(SelectInDir); SelectOutPathCommand = new ReactiveCommand(CanOperation).WithSubscribe(SelectOutPath); ExportCommand = new AsyncReactiveCommand(canExport, CanOperation).WithSubscribe(Export); CloseCommand = new ReactiveCommand <Window>(CanOperation).WithSubscribe(Close); // 入力元フォルダパスが変更された時、言語一覧を更新する InDirPath.Subscribe(path => { Langages.ClearOnScheduler(); Langages.AddRangeOnScheduler(_Model.GetLangages(path)); }); }
private void Start() { // AsyncReactiveCommand<Unit>と同義 var asyncReactiveCommand = new AsyncReactiveCommand(); // ButtonとBind asyncReactiveCommand.BindTo(_button); // ボタンが押されたら3秒待つ asyncReactiveCommand.Subscribe(_ => { return(Observable.Timer(TimeSpan.FromSeconds(3)).AsUnitObservable()); }); // ボタンが押されたらサーバと通信する asyncReactiveCommand.Subscribe(_ => { return(FetchAsync("http://api.example.com/status") .ToObservable() .ForEachAsync(x => { _resultText.text = x; // 結果をUIに表示 })); }); }
public AddIRCommandDialogViewModel(Models.IRKit iRKit) { Name = new ReactiveProperty <string>("") .SetValidateAttribute(() => this.Name) .AddTo(disposables); IRCommandStr = new ReactiveProperty <string>("") .SetValidateAttribute(() => this.IRCommandStr) .AddTo(disposables); RegisterIRCommand = new[] { this.Name.ObserveHasErrors, IRCommandStr.ObserveHasErrors } .CombineLatest(x => x.All(y => !y)) .ToReactiveCommand() .WithSubscribe(_ => RegistIRCommand()) .AddTo(disposables); RegisterIRString = new AsyncReactiveCommand <object>() .WithSubscribe(async _ => await GetIRStringAsync()) .AddTo(disposables); CommandRegistStatus = new ReactiveProperty <string>("未登録").AddTo(disposables); this.iRKit = iRKit; }
public ReactiveSamplePanelViewModel(IReactiveSamplePanelAdapter samplePanelAdapter) { this.adapter = samplePanelAdapter; this.adapter.AddTo(this.disposables); this.hasId = new ReactivePropertySlim <bool>(false) .AddTo(this.disposables); this.Id = this.adapter.Person.Id .ToReactivePropertySlimAsSynchronized(x => x.Value) .AddTo(this.disposables); this.Name = this.adapter.Person.Name .ToReactivePropertySlimAsSynchronized(x => x.Value) .AddTo(this.disposables); this.BirthDay = this.adapter.Person.BirthDay .ToReactivePropertySlimAsSynchronized(x => x.Value) .AddTo(this.disposables); this.Age = this.adapter.Person.Age .ToReadOnlyReactivePropertySlim() .AddTo(this.disposables); this.Id.Subscribe(v => this.hasId.Value = v.HasValue); this.LoadClick = this.hasId .ToAsyncReactiveCommand() .WithSubscribe(() => this.onLoadClick()) .AddTo(this.disposables); this.SaveButtonClick = new AsyncReactiveCommand() .WithSubscribe(async() => await this.adapter.SavePersonAsync()) .AddTo(this.disposables); }
public static AsyncReactiveCommand CreateAsyncReactiveCommand(Func <Task> func) { var command = new AsyncReactiveCommand(); command.Subscribe(func); return(command); }
public AsyncLoginViewModel() { Tips = new StringReactiveProperty(INPUT_TIPS); InputNameCommand = new AsyncReactiveCommand <string>(); InputNameCommand.Subscribe(InputPassword); }
public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IGoogleService googleService, IFacebookService facebookService, IAppleService appleService) : base(navigationService) { _pageDialogService = pageDialogService; _googleService = googleService; _facebookService = facebookService; _appleService = appleService; _multiFactorService = new MultiFactorService(this); Title = "Main Page"; _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) => { _isSignedIn.Value = auth.CurrentUser != null; }); ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand(); SignUpCommand.Subscribe(SignUp); SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword); SignInWithGoogleCommand.Subscribe(SignInWithGoogle); SignInWithTwitterCommand.Subscribe(() => SignInWithProvider("twitter.com")); SignInWithFacebookCommand.Subscribe(SignInWithFacebook); SignInWithGitHubCommand.Subscribe(() => SignInWithProvider("github.com")); SignInWithYahooCommand.Subscribe(() => SignInWithProvider("yahoo.com")); SignInWithMicrosoftCommand.Subscribe(() => SignInWithProvider("microsoft.com")); SignInWithAppleCommand.Subscribe(SignInWithApple); SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber); SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously); ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>()); }
public MainPageViewModel(IPageDialogService pageDialog, ToDo todo) { Title = todo.ToReactivePropertyAsSynchronized(x => x.Title, ignoreValidationErrorValue: true) //ModelのTitleとシンクロして、エラー以降の値はModelにセットしない .SetValidateAttribute(() => this.Title); //Validationセット Description = todo.ToReactivePropertyAsSynchronized(x => x.Descriptions, ignoreValidationErrorValue: true) .SetValidateAttribute(() => this.Description); Priority = todo.ToReactivePropertyAsSynchronized( x => x.Priority, x => x.ToString(), // M->VMは文字列変換 x => { // VM->Mは数値変換 int ret; int.TryParse(x, out ret); return(ret); }, ignoreValidationErrorValue: true ) .SetValidateAttribute(() => this.Priority); TitleError = Title.ObserveErrorChanged .Select(x => x?.Cast <string>()?.FirstOrDefault()) //発生したエラーの最初の値を文字列として取得 .ToReadOnlyReactiveProperty(); DescriptionError = Description.ObserveErrorChanged .Select(x => x?.Cast <string>()?.FirstOrDefault()) .ToReadOnlyReactiveProperty(); PriorityError = Priority.ObserveErrorChanged .Select(x => x?.Cast <string>()?.FirstOrDefault()) .ToReadOnlyReactiveProperty(); DateTo = todo.ToReactivePropertyAsSynchronized(x => x.DateTo, ignoreValidationErrorValue: true); DateFrom = todo.ToReactivePropertyAsSynchronized(x => x.DateFrom, ignoreValidationErrorValue: true); CombineDate = new[] { DateFrom, DateTo }.CombineLatest() //開始日、終了日をドッキングして .ToReactiveProperty() //ReactiveProperty化して .SetValidateAttribute(() => this.CombineDate); //カスタムルールを適用 //それをエラーに流す DateError = CombineDate.ObserveErrorChanged.Select(x => x?.Cast <string>()?.FirstOrDefault()).ToReadOnlyReactiveProperty(); OKCommand = new[] { Title.ObserveHasErrors, Description.ObserveHasErrors, Priority.ObserveHasErrors, CombineDate.ObserveHasErrors }.CombineLatest(x => x.All(y => !y)).ToAsyncReactiveCommand(); //エラーをまとめてCommand化 OKCommand.Subscribe(async _ => { await pageDialog.DisplayAlertAsync("", "Done", "OK"); }); }
public MainPageViewModel(INavigationService navigationService, IDialogService dialogService) : base(navigationService, dialogService) { TestCommand = new AsyncReactiveCommand(); TestCommand.Subscribe(async() => { await _navigationService.NavigateAsync(nameof(NextPage)); }); }
public ViewModel() { Command = new AsyncReactiveCommand(); Command.Subscribe(async _ => { await _model.Add(); }); }
public static IDisposable SubscribeAsDialogCommand(this AsyncReactiveCommand command, IDialog dialog, bool dialogResult, Func <Task <bool> > onExecute) { return(command.Subscribe(async() => { if (await onExecute()) { dialog.CloseWindow(dialogResult); } })); }
public WatchItLater( IScheduler scheduler, SubscriptionManager subscriptionManager, Models.Provider.LoginUserHistoryProvider loginUserDataProvider, UseCase.Playlist.PlaylistAggregateGetter playlistAggregate ) { Scheduler = scheduler; SubscriptionManager = subscriptionManager; LoginUserDataProvider = loginUserDataProvider; _playlistAggregate = playlistAggregate; Refresh = new AsyncReactiveCommand(); Refresh.Subscribe(async() => await Update()) .AddTo(_disposables); { var localObjectStorageHelper = new LocalObjectStorageHelper(); IsAutoUpdateEnabled = localObjectStorageHelper.Read(nameof(IsAutoUpdateEnabled), true); AutoUpdateInterval = localObjectStorageHelper.Read(nameof(AutoUpdateInterval), DefaultAutoUpdateInterval); } this.ObserveProperty(x => x.IsAutoUpdateEnabled) .Subscribe(x => { var localObjectStorageHelper = new LocalObjectStorageHelper(); localObjectStorageHelper.Save(nameof(IsAutoUpdateEnabled), IsAutoUpdateEnabled); }) .AddTo(_disposables); this.ObserveProperty(x => x.AutoUpdateInterval) .Subscribe(x => { var localObjectStorageHelper = new LocalObjectStorageHelper(); localObjectStorageHelper.Save(nameof(AutoUpdateInterval), AutoUpdateInterval); }) .AddTo(_disposables); Observable.Merge(new[] { this.ObserveProperty(x => x.IsAutoUpdateEnabled).ToUnit(), this.ObserveProperty(x => x.AutoUpdateInterval).ToUnit() }) .Subscribe(x => { if (IsAutoUpdateEnabled) { StartOrResetAutoUpdate(); } else { StopAutoUpdate(); } }) .AddTo(_disposables); App.Current.Suspending += Current_Suspending; App.Current.Resuming += Current_Resuming; }
public ParsePlayer() { LoginCommand = new AsyncReactiveCommand(sharedCanExecute); SignupCommand = new AsyncReactiveCommand(sharedCanExecute); FBLoginCommand = new AsyncReactiveCommand(sharedCanExecute); LogoutCommand = new AsyncReactiveCommand(sharedCanExecute); UpdateCommand = new AsyncReactiveCommand(sharedCanExecute); FBLinkCommand = new AsyncReactiveCommand(sharedCanExecute); }
public AppNavigationRootPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator) { _navigationService = navigationService; _eventAggregator = eventAggregator; MasterPageItems = new List <MasterPageListItem> { new MasterPageListItem { Title = "ホーム", Icon = iOSIconHome, PageName = nameof(Pages.HomePageViewModel).GetViewNameFromRule() }, new MasterPageListItem { Title = "模擬店/展示", Icon = iOSIconList, PageName = nameof(Pages.PlanningListRootPageViewModel).GetViewNameFromRule() }, new MasterPageListItem { Title = "ステージイベント", Icon = iOSIconStage, PageName = nameof(Pages.StageEventListRootPageViewModel).GetViewNameFromRule() }, new MasterPageListItem { Title = "マップ", Icon = iOSIconMap, PageName = nameof(Pages.FestaMapRootPageViewModel).GetViewNameFromRule() }, new MasterPageListItem { Title = "投票", Icon = iOSIconVote, PageName = nameof(Pages.VoteAnnouncePageViewModel).GetViewNameFromRule() }, }; SelectedItemCommand = new AsyncReactiveCommand <MasterPageListItem>(); SelectedItemCommand.Subscribe(async(item) => { await NavigationPageWrappedNavigation(item.PageName); }).AddTo(this.Disposable); ReactiveCurrentTabIndex.Subscribe((value) => { switch (value) { case 0: _eventAggregator.GetEvent <TabbedPageOpendEvent>().Publish(new TabbedPageOpendEventArgs(nameof(Pages.HomePageViewModel).GetViewNameFromRule())); break; case 1: _eventAggregator.GetEvent <TabbedPageOpendEvent>().Publish(new TabbedPageOpendEventArgs(nameof(Pages.PlanningListRootPageViewModel).GetViewNameFromRule())); break; case 3: _eventAggregator.GetEvent <TabbedPageOpendEvent>().Publish(new TabbedPageOpendEventArgs(nameof(Pages.FestaMapRootPageViewModel).GetViewNameFromRule())); break; case 4: _eventAggregator.GetEvent <TabbedPageOpendEvent>().Publish(new TabbedPageOpendEventArgs(nameof(Pages.VoteAnnouncePageViewModel).GetViewNameFromRule())); break; default: break; } }).AddTo(this.Disposable); ReactiveCurrentTabIndex.AddTo(this.Disposable); }
public Item() { Message = new ReactiveProperty <string>(); Command = new AsyncReactiveCommand() .WithSubscribe(async() => { Message.Value = "処理中"; await Task.Delay(3000); Message.Value = "処理完了"; }); }
private async UniTaskVoid Start() { var ap = new AsyncReactiveCommand <string>(_isEnabled); WaitCommandAsync(ap).Forget(); ap.Subscribe(_ => { return(Observable.Timer(TimeSpan.FromSeconds(2)).AsUnitObservable()); }); Observable.Timer(TimeSpan.FromSeconds(5)) .Subscribe(_ => ap.Execute("aaa")); }
public MainPageViewModel(INavigationService navigationService, PageModel pageModel) : base(navigationService) { PageDatas = pageModel.Pages.ToReadOnlyReactiveCollection(); ListTapped = new AsyncReactiveCommand <PageData>() .WithSubscribe(async(x) => { var p = new NavigationParameters { { "PageData", x } }; await navigationService.NavigateAsync("Page1", p); }); }
public ContractViewModel(IYubaba yubaba, IEventAggregator eventAggregator) { Yubaba = yubaba ?? throw new ArgumentNullException(nameof(yubaba)); EventAggregator = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator)); SubmitCommand = new AsyncReactiveCommand() .WithSubscribe(async() => await Yubaba.SubmitContractAsync(new ContractPaper(SignatureSign.Value))) .AddTo(Disposables); EventAggregator.GetEvent <ResetEvent>() .Subscribe(() => SignatureSign.Value = "") .AddTo(Disposables); }
public CommandViewModel(IYubaba yubaba, IEventAggregator eventAggregator) { Yubaba = yubaba ?? throw new ArgumentNullException(nameof(yubaba)); EventAggregator = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator)); InitCommand = new AsyncReactiveCommand() .WithSubscribe(async() => { await Yubaba.RequestIntroductionAsync(); EventAggregator.GetEvent <ResetEvent>().Publish(); }) .AddTo(Disposables); }
/// <summary>コンストラクタ。</summary> public MainWindowViewModel() { this.relayStation = new CreatorRelayStation(); this.LogText = this.relayStation.Log .ToReadOnlyReactivePropertySlim() .AddTo(this.disposable); this.ContentRendered = new AsyncReactiveCommand() .WithSubscribe(() => this.onContentRenderedAsync()) .AddTo(this.disposable); }
public NotificationsViewModel(NotificationTabParameters param, IMastodonClient client) : base(param, null) { model = new NotificationsModel(client); Notifications = new ReadOnlyObservableCollection <Notification>(model); IsStreaming = model.StreamingStarted; ReloadCommand = new AsyncReactiveCommand().WithSubscribe(() => model.FetchPreviousAsync()); ReloadOlderCommand = new AsyncReactiveCommand().WithSubscribe(() => model.FetchNextAsync()); ToggleStreamingCommand = new ReactiveCommand().WithSubscribe(() => model.StreamingStarting.Value = !IsStreaming.Value); model.StreamingStarting.Value = param.StreamingOnStartup; ReloadCommand.Execute(); }
public DownloadViewModel(ApplicationContext applicationContext, IFormatSelectionViewModelFactory factory, IVideoDownloadService videoDownloadService, IApplicationService applicationService) { this.applicationContext = applicationContext; this.factory = factory; this.videoDownloadService = videoDownloadService; this.applicationService = applicationService; VideoUrl = applicationContext.ToReactivePropertyAsSynchronized(x => x.VideoUrl); SelectFormatCommand = new AsyncReactiveCommand().DisposeWith(this); SelectFormatCommand.Subscribe(x => OpenVideoFormatSelectionAsync()).DisposeWith(this); }
public SignInWithEmailAndPasswordPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService) { _pageDialogService = pageDialogService; Title = "Sign In "; SignInCommand = new[] { Email.Select(s => string.IsNullOrEmpty(s)), Password.Select(s => string.IsNullOrEmpty(s)) }.CombineLatest(x => x.All(y => !y)) .ToAsyncReactiveCommand(); SignInCommand.Subscribe(async() => { try { var result = await CrossFirebaseAuth.Current .Instance .SignInWithEmailAndPasswordAsync(Email.Value, Password.Value); await NavigationService.GoBackAsync(result.User); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); await _pageDialogService.DisplayAlertAsync("Failure", e.Message, "OK"); } }); ResetPasswordCommand = new[] { Email.Select(s => string.IsNullOrEmpty(s)), }.CombineLatest(x => x.All(y => !y)) .ToAsyncReactiveCommand(); ResetPasswordCommand.Subscribe(async() => { try { await CrossFirebaseAuth.Current .Instance .SendPasswordResetEmailAsync(Email.Value); await _pageDialogService.DisplayAlertAsync(null, "Email has been sent.", "OK"); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); await _pageDialogService.DisplayAlertAsync("Failure", e.Message, "OK"); } }); }
public SignInWithPhoneNumberPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService) { Title = "Phone Numbe"; _pageDialogService = pageDialogService; SignInCommand = PhoneNumber.Select(s => !string.IsNullOrEmpty(s)).ToAsyncReactiveCommand(); SignInCommand.Subscribe(async() => { try { PhoneNumberVerificationResult verificationResult; if (_multiFactorSession != null) { verificationResult = await CrossFirebaseAuth.Current.PhoneAuthProvider .VerifyPhoneNumberAsync(PhoneNumber.Value, _multiFactorSession); } else { verificationResult = await CrossFirebaseAuth.Current.PhoneAuthProvider .VerifyPhoneNumberAsync(PhoneNumber.Value); } if (verificationResult.Credential != null) { await NavigationService.GoBackAsync(verificationResult.Credential); } else { var verificationCode = await NavigationService.NavigateAsync <VerificationCodePageViewModel, string>(); if (verificationCode != null) { var credential = CrossFirebaseAuth.Current.PhoneAuthProvider .GetCredential(verificationResult.VerificationId, verificationCode); await Task.Delay(TimeSpan.FromMilliseconds(1)); await NavigationService.GoBackAsync(credential); } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); await _pageDialogService.DisplayAlertAsync("Failure", e.Message, "OK"); } }); }
public SignupPageViewModel(INavigationService navigationService, ISignupService signupService, IPageDialogService pageDialogService) : base(navigationService) { _signupService = signupService; _pageDialogService = pageDialogService; Title = "サインアップ"; Email = _signupService.Email; Name = _signupService.Name; Password = _signupService.Password; _signupService.Image.Value = "user.png"; _signupService.SignupCompletedNotifier .ObserveOn(SynchronizationContext.Current) .SelectMany(_ => { var navigation = NavigationFactory.Create <MainPageViewModel>() .Add(NavigationNameProvider.DefaultNavigationPageName) .Add <HomePageViewModel>(); return(NavigateAsync(navigation, noHistory: true)); }) .Subscribe() .AddTo(_disposables); _signupService.SignupErrorNotifier .ObserveOn(SynchronizationContext.Current) .Subscribe(_ => _pageDialogService.DisplayAlertAsync("エラー", "サインアップに失敗しました", "OK")) .AddTo(_disposables); _signupService.IsSigningUp .Skip(1) .Where(b => b) .ObserveOn(SynchronizationContext.Current) .SelectMany(_ => NavigateAsync <LoadingPageViewModel>()) .Subscribe() .AddTo(_disposables); _signupService.IsSigningUp .Skip(1) .Where(b => !b) .ObserveOn(SynchronizationContext.Current) .SelectMany(_ => GoBackAsync()) .Subscribe() .AddTo(_disposables); SignupCommand = _signupService.CanSignup .ToAsyncReactiveCommand() .AddTo(_disposables); SignupCommand.Subscribe(async() => await _signupService.Signup()); }
public MainWindow(Models.IStreamManager streamManager) { // DI container から modelを受け取る this._streamManager = streamManager; this.Text = new ReactivePropertySlim <string>("Write any text here!") .AddTo(this._disposable); //this.Text=new ReactivePropertySlim<string>(await this._streamManager.ReadTextAsync()) this.SaveTextCommand = new AsyncReactiveCommand() .WithSubscribe(async _ => await this._streamManager.WriteTextAsync(this.Text.Value).ConfigureAwait(false)) .AddTo(this._disposable); }
public void DefaultConstructor() { var command = new AsyncReactiveCommand(); var task1 = new TaskCompletionSource<object>(); var task2 = new TaskCompletionSource<object>(); command.Subscribe(_ => task1.Task); command.Subscribe(_ => task2.Task); command.Execute(); command.CanExecute().IsFalse(); task1.SetResult(null); command.CanExecute().IsFalse(); task2.SetResult(null); command.CanExecute().IsTrue(); }
public void RemoveSubscription() { var command = new AsyncReactiveCommand(); var task1 = new TaskCompletionSource<object>(); var task2 = new TaskCompletionSource<object>(); var subscription1 = command.Subscribe(_ => task1.Task); var subscription2 = command.Subscribe(_ => task2.Task); subscription2.Dispose(); command.Execute(); command.CanExecute().IsFalse(); task1.SetResult(null); command.CanExecute().IsTrue(); }