I have a stream of Foo. Foo emits require Android View to be laid out (width and height > 0). I use RxBinding for that i.e.
fooOservable()
.subscribe(foo -> {});
RxView.preDraws(mPager, () -> true)
.take(1);
When this observable emits (or completed, cuz of the take) view is laid out.
What I need is for fooObservable() to wait until RxView emits, i.e. view is laid out. I cant just fooObservable.filter( width && height > 0 ), because that drops the emits. What I need is to have the last emit of foo cached (if view not laid out) and reemitted after first RxView.preDraws., if it is laid out, it should pass normally
You can use
delay
ordelaySubsription
. There are forms which delay emitions or subscription until another observable emits something. In the first case you will have just emition delay, in the second case the whole subscription will be delayed.