I'm using Composes collectAsState() function to collect from this StateFlow
val _authToken = MutableStateFlow(AuthToken("", 0))
val authToken: StateFlow<AuthToken> = _authToken
val authToken by loginViewModel.authToken.collectAsState() // this returns AuthToken which is fine.
However, when turning a cold flow into a stateflow using the stateIn operator then using collectAsState() it returns a State version of the object which is odd then I need to call .value on collectAsState() to retrieve it.
Does anyone know why this happens?
val user = repository.getUser(viewModelScope).stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), null)
val user = profileViewModel.user.collectAsState() // returns State<User>