public ViewController(IntPtr handle)
     : base(handle)
 {
     UseCase useCase = new UseCase ();
     IScheduler scheduler = new MainThreadScheduler ();
     presenter = new Presenter (useCase.Models, scheduler);
 }
Beispiel #2
0
        static RxApp()
        {
            DefaultExceptionHandler = Observer.Create <Exception>(
                ex =>
            {
                // NB: If you're seeing this, it means that an
                // ObservableAsPropertyHelper or the CanExecute of a
                // ReactiveCommand ended in an OnError. Instead of silently
                // breaking, ReactiveUI will halt here if a debugger is attached.
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }

                MainThreadScheduler.Schedule(
                    () =>
                {
                    throw new Exception(
                        "An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects",
                        ex);
                });
            });

            if (MainThreadScheduler == null)
            {
                MainThreadScheduler = DefaultScheduler.Instance;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initializes static members of the <see cref="RxApp"/> class.
        /// </summary>
        /// <exception cref="UnhandledErrorException">Default exception when we have unhandled exception in RxUI.</exception>
        static RxApp()
        {
#if !PORTABLE
            _taskpoolScheduler = TaskPoolScheduler.Default;
#endif

            Locator.RegisterResolverCallbackChanged(() =>
            {
                if (Locator.CurrentMutable == null)
                {
                    return;
                }

                Locator.CurrentMutable.InitializeReactiveUI();
            });

            DefaultExceptionHandler = Observer.Create <Exception>(ex =>
            {
                // NB: If you're seeing this, it means that an
                // ObservableAsPropertyHelper or the CanExecute of a
                // ReactiveCommand ended in an OnError. Instead of silently
                // breaking, ReactiveUI will halt here if a debugger is attached.
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }

                MainThreadScheduler.Schedule(() =>
                {
#pragma warning disable CA1065 // Avoid exceptions in constructors -- In scheduler.
                    throw new UnhandledErrorException(
                        "An object implementing IHandleObservableErrors (often a ReactiveCommand or ObservableAsPropertyHelper) has errored, thereby breaking its observable pipeline. To prevent this, ensure the pipeline does not error, or Subscribe to the ThrownExceptions property of the object in question to handle the erroneous case.",
                        ex);
#pragma warning restore CA1065
                });
            });

            if (ModeDetector.InUnitTestRunner())
            {
                LogHost.Default.Warn("*** Detected Unit Test Runner, setting MainThreadScheduler to CurrentThread ***");
                LogHost.Default.Warn("If we are not actually in a test runner, please file a bug\n\n");
                LogHost.Default.Warn("ReactiveUI acts differently under a test runner, see the docs\n");
                LogHost.Default.Warn("for more info about what to expect");

                _mainThreadScheduler = CurrentThreadScheduler.Instance;
                return;
            }

            LogHost.Default.Info("Initializing to normal mode");

            if (_mainThreadScheduler == null)
            {
                _mainThreadScheduler = DefaultScheduler.Instance;
            }

            SuspensionHost = new SuspensionHost();
        }
 static ExceptionHandler()
 {
     Default = Observer.Create <Exception>(ex => {
         MainThreadScheduler.Schedule(() => {
             throw new Exception(
                 "An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects",
                 ex);
         });
     });
 }