Colton Idle
06/30/2022, 9:09 AM@Singleton
class AppStateHolder() {
var someBoolean by mutableStateOf(false)
Filip Wiesner
06/30/2022, 10:33 AMState > Flow
(for this UC). You can always create Flow
from Compose State
using snapshotFlow
🤷Sean McQuillan [G]
06/30/2022, 11:37 PMsnapshotFlow
was added as an API to make this sort of usage reasonable
If you're doing a lot of reactive transforms, then State doesn't provide the best API
If you're doing state, it does what it says on the tinColton Idle
07/01/2022, 5:05 PMSean McQuillan [G]
07/01/2022, 5:09 PMSean McQuillan [G]
07/01/2022, 5:09 PMSean McQuillan [G]
07/01/2022, 5:10 PMSean McQuillan [G]
07/01/2022, 5:11 PMclass AppStateHolder {
val currentUser: StateFlow...
@Composable fun currentUserState() = currentUser.collectAsState
Or the inverse
class AppStateholder {
val currentUser by mutableStateOf...
fun currentUserFlow() = snapshotFlow { currentUser }
Sean McQuillan [G]
07/01/2022, 5:13 PMColton Idle
07/01/2022, 5:16 PM@Singleton
class AppStateHolder {
val someAppState: MutableStateFlow<Boolean> = MutableStateFlow...
val currentUser: MutableStateFlow<User> = MutableStateFlow...
I think the only "bad" thing is that I'm using mutableStateFlow, but I think my only option would be to use a backing property and my team all kinda hates them so we dont use backing properties. /shruggie