示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        model = new CounterModel_A();
        // Nullチェック
        if (null == view)
        {
            view = FindObjectOfType <CounterView_Q>();
        }

        //ここから記述
        #region Question
        // viewを参照

        // AddObservableが発火した時

        // 購読してmodelのAddCountを実行する


        // viewを参照 .

        // ReduceObservableが発火した時.

        // 購読してmodelのReduceCountを実行する


        //  modelを参照する

        // Counterの値に変化があった時

        // modelのCounterの値を引数にviewのDisplayCountを実行する
        #endregion
        //ここまで
    }
    // Start is called before the first frame update
    void Start()
    {
        model = new CounterModel_A();
        // NullCheck for carelessness.
        if (null == view)
        {
            view = FindObjectOfType <CounterView_A>();
        }

        // Browse to the view.
        view
        // When fired AddObservable.
        .AddObservable()
        // Subscribe and notify the model of the AddCount.
        .Subscribe(_ => model.AddCount())
        .AddTo(this);

        // Browse to the view.
        view
        // When fired ReduceObservable.
        .ReduceObservable()
        // Subscribe and notify the model of the ReduceCount.
        .Subscribe(_ => model.ReduceCount())
        .AddTo(this);

        // Browse to the model.
        model
        // When change in the count value.
        .Counter
        // Notify the view of numerical changes.
        .Subscribe(_ => view.DisplayCount(model.Counter.Value))
        .AddTo(this);
    }