Okay, bear with me. Now that StateFlows are a thin...
# coroutines
c
Okay, bear with me. Now that StateFlows are a thing... why would you use any other Flow? Isn't everything "state"?
🚫 5
i
Events are not state
f
and state flows are hot
d
What Ian said. Use flow a lot for stuff like events and one time messages
s
@Francesc Hot or cold flows are not defined whether they have state or not, whether they are conflated or not. StateFlows are 🔥 though 😀 Hot flows are active whether someone is listening/observing/collecting or not. Cold flows are only active while and as long someone is listening/observing/collecting.
f
right, and a
mutableStateFlow
is hot, which was my point, being hot may not be what you are after
👍 1
c
Thank you all! A bit of Saturday morning pondering with my
p
Consider a function that does some work and emit consecutive status updates to caller. It makes sense that ie returns a Flow built from
flow { }
Though I personally prefer to have updates sent as callbacks and result as the function return type
a
Events describe change, state describe “stationary” data. A state flow is a data type which has a defined state at every moment in time. How would you model a Kafka stream with Stateflow? There isn’t any defined state at every moment in time.
s
Kafka being an event driven architecture, a SharedFlow would fit. But stateful consumers of these events could model themselves upstream as a StateFlow (state is stored in a DB, for example).