What’s the difference between these two ways of ex...
# getting-started
a
What’s the difference between these two ways of exposing MutableStateFlow as StateFlow?
Copy code
private val _data = MutableStateFlow(0)
1. val data: StateFlow<Int> = _data
2. val data = _data.asStateFlow()
In other words, what does
asStateFlow()
do?
b
In the 1st example
data
can still be cast back to
MutableStateFlow
1️⃣ 1
k
In the first case you can still do something like:
(_data as MutableStateFlow).emit()
a
Got it, thanks!!!