예제 #1
0
        public RedViewModel(IViewStackService viewStackService) : base(viewStackService)
        {
            PopModal = ReactiveCommand
                       .CreateFromObservable(() =>
                                             ViewStackService.PopModal(),
                                             outputScheduler: RxApp.MainThreadScheduler);

            PopPage = ReactiveCommand
                      .CreateFromObservable(() =>
                                            ViewStackService.PopPage(),
                                            outputScheduler: RxApp.MainThreadScheduler);

            PushPage = ReactiveCommand
                       .CreateFromObservable(() =>
                                             ViewStackService.PushPage(new RedViewModel(ViewStackService)),
                                             outputScheduler: RxApp.MainThreadScheduler);
            PopToRoot = ReactiveCommand
                        .CreateFromObservable(() =>
                                              ViewStackService.PopToRootPage(),
                                              outputScheduler: RxApp.MainThreadScheduler);

            PopModal.Subscribe(x => Debug.WriteLine("PagePushed"));
            PopModal.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe());
            PopPage.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe());
            PushPage.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe());
            PopToRoot.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe());
        }