Hi All, My question as below <Is collectAsStateWit...
# compose
e
Hi All, My question as below Is collectAsStateWithLifecycle only applicable to cold flow, and not helpful for hot flow (e.g. stateFlow)? If not, can somehow show me how hotflow (e.g. stateFlow) differs when using
collectAsStateWithLifecycle
vs
collectAsState
? Thanks.
I got the answer from the Author https://twitter.com/manuelvicnt/status/1587006978076938240 I tried
Copy code
val state = savedStateHandle
        .getStateFlow(KEY, 0)
        .stateIn(
            viewModelScope,
            WhileSubscribed(5000),
            0
        )
it works well when
Copy code
val collected = stateFlow.collectAsStateWithLifecycle(0)