[RESOLVED] What's the difference between casting t...
# coroutines
t
[RESOLVED] What's the difference between casting to
StateFlow
vs
asStateFlow
? 🧵
message has been deleted
Which one is recommended/preferred?
d
The latter. I think it's because it prevents down casting to the
MutableStateFlow
.
2
j
If you check the implementation,
asSharedFlow
and
asStateFlow
actually wrap your flow in a read-only instance. So people cannot down cast back to a mutable one and potentially mess up your state
2
t
Understood 🙇‍♂️
u
I use the cast. Unless youre a library or something