darkmoon_uk
02/23/2023, 7:43 AMStateFlow
s using the new API collectAsStateWithLifecycle
on Android are well explained in this article.
alphabet yellow question For those of us developing for K *Compose/Multiplatform*; what's the most ergonomic way to achieve StateFlow
collection that has the benefits of collectAsStateWithLifecycle
on Android, while being able to reuse (mostly) the same View code on other platforms?hfhbd
02/23/2023, 8:20 AMArkadii Ivanov
02/23/2023, 9:16 AMcollectAsStateWithLifecycle
will actually save resources in background only when the Flow is cold. In many cases the Flow in a ViewModel is backed by MutableStateFlow
which is hot. In such cases only re-rendering will be avoided (which might be negligible anyway), the ViewModel will keep working in the background.
This is how I understand the picture.gildor
02/23/2023, 9:42 AM