Marc Knaup
01/11/2021, 11:49 AMemit()
invocation of a MutableSharedFlow
until all subscribers have completed collecting the element? There’s no replay.elizarov
01/12/2021, 2:14 PMbuffer
operator or other similar ones) and there is no support for "processing completed" signal in the flow infrastructure.Marc Knaup
01/12/2021, 2:20 PMbezrukov
01/12/2021, 10:34 PMvalue
. (Note that you will need some extra synchronization to always send value+confirmation paired) On collector side you will need to filter such tokens.
If it's ok to receive "processing complete" with few extra redispatches it might work for you.Marc Knaup
01/13/2021, 9:22 AMn
confirmations where n
is determined the moment you emit.bezrukov
01/13/2021, 9:32 AMfast collected 1
slow collected 1
confirmed 1
fast collected 2
slow collected 2
confirmed 2
fast collected 3
slow collected 3
confirmed 3
fast collected 4
slow collected 4
confirmed 4
fast collected 5
slow collected 5
confirmed 5
Marc Knaup
01/13/2021, 9:35 AMbezrukov
01/13/2021, 9:36 AMemitWithConfirmation
and use only it. Then every new emitter will wait for previous confirmationmutex.withLock {
flow.emit(value)
flow.emit(specialToken)
}
Marc Knaup
01/13/2021, 9:38 AMelizarov
01/13/2021, 9:40 AMMarc Knaup
01/13/2021, 9:55 AMelizarov
01/13/2021, 10:05 AMinterface XyzEventHandler
with a suspend fun processEvent(...)
and then inject its implementation into the place which generates those events. Synchronous and simple.Marc Knaup
01/13/2021, 10:09 AMMutableSharedFlow
that I've used one instead and can benefit from all Flow API and guarantees (esp. cancelation/unsubscribe). It works great except that it doesn't wait for collectors.elizarov
01/13/2021, 10:10 AMInsuranceQuoteAddedHandler
, then I'm 100% sure that there is a handler that did process added insurance quote, or my dependencies would fail to wire).Marc Knaup
01/13/2021, 10:11 AMelizarov
01/13/2021, 10:14 AMMarc Knaup
01/13/2021, 10:17 AMelizarov
01/13/2021, 10:19 AMMarc Knaup
01/13/2021, 10:21 AMelizarov
01/13/2021, 10:26 AMMarc Knaup
01/13/2021, 10:27 AMemit
in flow {}
would return if a context switch happens but before the collection of the element has completed?elizarov
01/13/2021, 10:27 AMMarc Knaup
01/13/2021, 10:28 AMelizarov
01/13/2021, 10:29 AMAnother thing to observe here is that the flowOn operator has changed the default sequential nature of the flow.
Marc Knaup
01/13/2021, 10:30 AMFlow
isn’t meant to be used in such cases, there’s no point in making it work. I’ll work on my own synchronous stream solution then.elizarov
01/13/2021, 12:01 PMSynchronousSharedFlow
implementation (I don't have a better name) that actually suspends emit
until all active collectors have "finished processing it".Marc Knaup
01/13/2021, 12:04 PMMutableSharedFlow
(as a workaround)?
How much would a clean implementation differ from a MutableSharedFlow
? And does it make sense to even support replay
for such Flows?elizarov
01/13/2021, 12:26 PMMarc Knaup
01/13/2021, 12:35 PM