Skip to content

Instantly share code, notes, and snippets.

View m-maillot's full-sized avatar
🏠
Working from home

Martial Maillot m-maillot

🏠
Working from home
View GitHub Profile
@m-maillot
m-maillot / broken_animation.kt
Created March 25, 2021 10:14
When broken the animation
data class Bubble(val id: Int, val isBig: Boolean)
class TryViewModel : ViewModel() {
private val _uiState = MutableStateFlow<List<Bubble>>((1..6).map { Bubble(it, false) })
val uiState: StateFlow<List<Bubble>> = _uiState
fun run() = viewModelScope.launch(Dispatchers.Default) {
_uiState.value.forEachIndexed { index, value ->
delay(1000)
_uiState.value = _uiState.value.updated(index, value.copy(isBig = value.isBig.not()))
}
}