Unity/UniRx/Observable
提供: 初心者エンジニアの簡易メモ
Observable.Createを使う
Observable.Create<int>(observer => { for (var i = 1; i <= 3; i++) { observer.OnNext(i); } Debug.Log("Finished"); observer.OnCompleted(); return Disposable.Create(() => { Debug.Log("Dispose"); }); }).Subscribe(x => Debug.Log(x));
ログ
1 2 3 Finished Dispose