What is the use case for flows?
# coroutines
a
What is the use case for flows?
z
multiple values over time
a
For what use case tho?
z
are you familiar with RxJava?
or LiveData<T>
a
Yes
z
that’s the use case
a
Thats not a use case
A use case is like when a user is typing then you do foobar
z
okay
for a ViewModel to expose a stream of states
a
Preferably examples on server side than UI side
z
it would be represented as
Flow<State>
a
Basics events?
z
I don’t do server side dev so I couldn’t tell you
a
Basically #
z
yes, events would qualify
in any place you would set a listener to receive callbacks for multiple values over time,
Flow<T>
makes sense
for a single value,
suspend () -> T
should be preferred
a
Hmm i guess that kinda makes sense
Wonder how to use it backend side
z
a socket connection?
(maybe)
a
How?
Lol
z
subscribing to a
Flow<T>
would create a socket connection containing events of type
T
g
Every stream of events can be represented as Flow: Server requests, socket connection, database updates, periodical events etc Essentially everything where you use callbacks that can be called multiple times. For example check how Spring uses Reactor (which is also reactive library), you can represent whole web service as chain of events where source is request that converted to response event