Example #1
0
        protected override void Complete()
        {
            // This method is automatically called (after all bindings have been configured) to
            // launch the app. Here we simply ask the main NavigationControl (responsible for
            // displaying pages) to display the Catalog model. Because Catalog is just pure data,
            // it will automatically be wrapped into a CatalogViewModel, which will then be
            // displayed with a CatalogView (MonoBehaviour) in a CatalogPage prefab. The
            // NavigationControl has also been tagged with a "Page" variant, which will ensure
            // that anything that gets displayed in it will use the "Page" variant among possible
            // prefab visuals.

            Log.Info("Presenting Catalog (model) -> CatalogViewModel -> CatalogView -> CatalogPage (prefab)");

            NavigationControl
            .Present(new Catalog())
            .AutoDetach()
            .Subscribe(_ => {}, ex => Log.Error("Failed to navigate", ex), () => {});

            // If you wonder about the .AutoDetach().Subscribe() part, that's because
            // the .Present() method returns an Rx observable that needs to be subscribed to.
            // If you do not subscribe to the returned observable, nothing will happen. As for
            // AutoDetach(), it automatically disposes the subscription as soon as the observable
            // completes; but should only be used with observables that complete at some point,
            // otherwise, the subscription will never be disposed and you will end-up with a leak.
            //
            // For more information about Rx (Reactive Extensions or ReactiveX) in general see:
            // http://reactivex.io/
            //
            // For more information about UniRx (the Unity version of Rx) see:
            // https://github.com/neuecc/UniRx
        }