Ivan Đorđević
10/26/2021, 9:19 AMSharedFlow
that caches values (like replayCache
) but DOESN'T play them back automatically to new subscribers?wbertan
10/26/2021, 9:25 AMfun <T> MutableSingleSharedFlow() = MutableSharedFlow<T>(
replay = 1,
extraBufferCapacity = 1,
onBufferOverflow = BufferOverflow.DROP_OLDEST
)
Not sure it “DOESN’T play them back automatically” 🤔Ivan Đorđević
10/26/2021, 9:26 AMreplay = 1
so it seems it would replay one valuebezrukov
10/26/2021, 9:26 AMIvan Đorđević
10/26/2021, 9:27 AMreplayCache.size() == 0
still even after emitting somethingbezrukov
10/26/2021, 9:32 AMflow.drop(flow.replayCache.size())
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).Dominaezzz
10/26/2021, 9:40 AMSharedFlow
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).