What is use case of coroutines flow ? What does it...
# coroutines
r
What is use case of coroutines flow ? What does it provide ?
z
Flow<T>
should be used when a class exposes multiple values of
T
so any use case where you would register a listener for multiple emissions,
Flow<T>
should be used
if it’s a single asynchronous value, then
suspend () -> T
is the proper type
r
Any example for multiple emissions ? In respect to Android would be much better 😅
g
On Android it may be every callback-based API, you can convert onClickListener events to flow and any other View event, BroadcastReceiver.onReceive and many other
The same as RxJava and similar to LiveData
s
A Flow is reactive and it will, when active, emit objects/data over time. Like Andrey said, Flow is similar to a cold observable in Rx (Java).
r
Cool I get it now .
I would try to convert onClicklisteners to flow