コード例 #1
0
        public IObservable <SceneModel> LoadSceneAsObservable(string sceneName, LoadSceneMode loadSceneMode)
        {
            var stream = RoutingRepository
                         .LoadSceneAsObservable(sceneName, loadSceneMode)
                         .SelectMany(x => RoutingTranslator.TranslateAsObservable(x))
                         .Share();

            // OnComplete を流してしまうと、Subject が閉じてしまうので OnNext, OnError のみを流す
            stream
            .Subscribe(
                (x) =>
            {
                if (x.Controller == default(IController))
                {
                    LoadSceneSubject.OnError(new NullReferenceException($"The component what implements `CAFU.Core.Presentation.View.IController` does not found in destination scene. Please check `{x.Name}` scenes to see if `Controller` component is attached."));
                }
                else
                {
                    LoadSceneSubject.OnNext(x);
                }
            },
                LoadSceneSubject.OnError
                );
            return(stream);
        }
コード例 #2
0
        public IObservable <SceneModel> UnloadSceneAsObservable(string sceneName)
        {
            var stream = RoutingRepository
                         .UnloadSceneAsObservable(sceneName)
                         .SelectMany(x => RoutingTranslator.TranslateAsObservable(x))
                         .Share();

            // OnComplete を流してしまうと、Subject が閉じてしまうので OnNext, OnError のみを流す
            stream
            .Subscribe(
                UnloadSceneSubject.OnNext,
                UnloadSceneSubject.OnError
                );
            return(stream);
        }