Hi. I'm trying to display log messages in a view u...
# coroutines
e
Hi. I'm trying to display log messages in a view using a Flow. Log messages are streamed over the network, I can't query them, only receive them one by one. I want to cache a given amount of messages in-memory, say 10 000, but only show the last N messages in the view (based on user options). I thought Flow would be great since the view would not consume the flow when not open, and when open user options such as filtering could be applied, and new messages would end up in the view.
s
Check out sharedFlow. It has replay and buffer options that might help you.
e
Thanks, that seems to work fine
Is it possible to get the buffer data beside collect? Not a big deal, but I want to write data from the buffer to a file
Looks like
replayCache
is what I want. I didn't see it because I passed around
Flow
, but I can change this to
SharedFlow