void Start() { // Code Here CounterModel.Subject .StartWith(CounterModel.State) .Subscribe(state => { Number.text = state.Count.ToString(); }); BtnAdd.onClick.AddListener(() => { CounterModel.Dispatch("increase"); }); BtnSub.onClick.AddListener(() => { CounterModel.Dispatch("decrease"); }); }
void Start() { // 初始化从服务器拉取数据 CounterModel.Effects.PullDataFromNetwork(); // Code Here CounterModel.Subject .StartWith(CounterModel.State) .Subscribe(state => { Number.text = state.Count.ToString(); }); BtnAdd.onClick.AddListener(() => { CounterModel.Dispatch("increase"); }); BtnSub.onClick.AddListener(() => { CounterModel.Dispatch("decrease"); }); }