These are chat archives for ReactiveX/RxJava

Sep 2018
James Fleming
Sep 09 2018 19:45
How can I buffer a Flowable until a Single completes?
Ignacio Baca Moreno-Torres
Sep 09 2018 22:01

I think this might work, but it is pretty weird… maybe you can rethink whatever you are trying to do in a more… reactive… way

Flowable<Long> buffer$ = Flowable.concatArrayEager(
        // maxConcurrency, prefetch,
        Completable.timer(1, SECONDS).toFlowable(),
        Flowable.interval(10, MILLISECONDS)/*.onBackpressureBuffer(capacity)*/);

you can use the commented code to control the buffering, if you have a single, that looks that it is actually a completable as you are ignoring its unique element, you can call .ignoreElement() and the again .toFlowable()

another, maybe more “natural” approach is to use a ConnectableFlowable and connect it manually, so it start buffering at that moment… but then you need to control the disconnect of this ConnectableFlowable, the example is longer so I use this weird previous example bc atleast the subscriptions are handled automatically
James Fleming
Sep 09 2018 22:19
I'm trying to implement an OrderBook system where there is a snapshot (the Single) and updates to the snapshot (which is a Flowable) Im wanting to make it as self managed as possible