Ivan Đorđević10/26/2021, 9:19 AM
that caches values (like
) but DOESN'T play them back automatically to new subscribers?
wbertan10/26/2021, 9:25 AM
Not sure it “DOESN’T play them back automatically” 🤔
fun <T> MutableSingleSharedFlow() = MutableSharedFlow<T>( replay = 1, extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST )
Ivan Đorđević10/26/2021, 9:26 AM
so it seems it would replay one value
replay = 1
bezrukov10/26/2021, 9:26 AM
Ivan Đorđević10/26/2021, 9:27 AM
still even after emitting something
replayCache.size() == 0
bezrukov10/26/2021, 9:32 AM
but I don't think it's robust because of different locks (I mean let's say replayCache contains [A,B,C] when you called it, but when you subscribed to it, A is dropped, and replay cache is [B, C, D], so you won't receive D).
Dominaezzz10/26/2021, 9:40 AM
early and maintain a list of n items emitted. Maybe even share the shared flow subscription, then you can use the new replay cache. (Although I don't think I'd call this a cache).