I'm developing an Android app and I'm torn between using Kotlin Coroutine's Flow and Channel for data stream processing.
Currently, I'm receiving network responses (Retrofit) as Flow and displaying them in the UI, while handling user actions (button clicks) with Channel. However, I recently needed a combine operation to merge multiple data sources, and I found Flow to be more convenient.
That said, I've heard that Channel, being a hot stream, can be tricky with memory management. Could you share your experience on how you decide between Flow and Channel in real projects?
If you receive network responses as a Flow, it's natural to handle them with Flow since Retrofit itself supports suspend functions. For user actions, Channel is also good, but I recently replaced it with SharedFlow. With the replay feature, buffering is possible, and there's no worry about missing data depending on the collect timing.
by 카페인중독11 · ▲0