neuecc / UniRx

Reactive Extensions for Unity
MIT License
7.01k stars 895 forks source link

Are there anyway to wait Initialize before Create ? #467

Open Thaina opened 3 years ago

Thaina commented 3 years ago

I have my custom listener function that I want it to wrap with UniRx. So I think I could use Create function. But then that custom listener need to initial before it could be used

And so I want to write something like

IObservable<MyValue> observable = Observable.EveryLateUpdate().WaitUntil(() => {
    return myListener.IsInit;
}).ThenCreate<MyValue>((observer) => {
    return myListener.Listen((value) => observer.OnNext(value));
});

I think there should be WaitUntil which is like Where but will fired only one time. And ThenCreate that will let me create custom listener with IObserver

What is efficient method in UniRx to make the flow as above?