MathCoroutinesFlow icon indicating copy to clipboard operation
MathCoroutinesFlow copied to clipboard

getUserStream should expose `Flow<User>`

Open ZakTaccardi opened this issue 5 years ago • 0 comments

https://github.com/manuelvicnt/MathCoroutinesFlow/blob/e7ccceda6847d815cae3ea3d4f179c3ac07765d2/app/src/main/java/com/manuelvicnt/coroutinesflow/user/impl/UserRepository.kt#L78-L80

This should be a Flow<User>, as UserRepository exposes an API that returns multiple instances of T over time.

ConflatedBroadcastChannel is basically a Flow<T>, as subscribing to it is cold behavior (open a subscription when you start collecting, close it when you stop collecting).

Another downside of ReceiveChannel<T> here is that it leaks how you unsubscribe. Using for(user in getUserStream) to observe would leave an opened channel.

ZakTaccardi avatar Oct 06 '19 20:10 ZakTaccardi