Suppose we have a class which maintains its state ...
# coroutines
m
Suppose we have a class which maintains its state as a list of `Item`s and exposes
add(item)
and
remove(item)
functions to manipulate the state. Suppose we want to expose the state as a
Flow<List<Item>>
. Would you: 1. Maintain a private property
MutableList<Item>
and set
MutableStateFlow<List<Item>>.value = items.toList()
inside
add()
and
remove()
and expose using
asStateFlow()
2. Use an
actor
with Add/Remove messages (sealed class) and use that to update a
MutableStateFlow
3. Something else?
1️⃣ 2
2️⃣ 1