Esempio n. 1
0
        private void Start()
        {
            // AsyncReactiveCommand型はAsyncReactiveCommand<Unit>型と同義
            var asyncReactiveCommand = new AsyncReactiveCommand();

            // ボタンを押したらサーバと通信する
            // 通信中はボタンを押せない(通信中はButtonのInteractiveがfalseになる)
            asyncReactiveCommand.BindToOnClick(_button, _ =>
            {
                return(FetchAsync("http://api.example.com/status")
                       .ToObservable()
                       .ForEachAsync(x =>
                {
                    _resultText.text = x;     // 結果をUIに表示
                }));
            });
        }