Colton Idle
08/31/2020, 7:39 PMviewModelScope.launch {
var initVal = 100
repeat(100) {
_myViewData.value =
_myViewData.value?.copy(initVal.toString())
initVal--
delay(1000)
}
}
Is there anything really bad with this approach? The only thing I can think of is how would the ViewModel being cleared would affect this.Adam Powell
08/31/2020, 8:06 PMfor
loop, the VM being cleared will stop the countdownAdam Powell
08/31/2020, 8:07 PMAdam Powell
08/31/2020, 8:08 PMliveData {}
builderColton Idle
08/31/2020, 8:08 PMint i = 0; ...
?
2. VM being cleared will stop the countdown? So it won't for repeat()
?Adam Powell
08/31/2020, 8:09 PMfor (value in 100 downTo 0)
Adam Powell
08/31/2020, 8:10 PMviewModelScope
, so any delay
call currently in progress will throw CancellationException
Colton Idle
08/31/2020, 8:10 PMColton Idle
08/31/2020, 8:17 PMrepeat()
with for(value...
Adam Powell
08/31/2020, 8:17 PMColton Idle
08/31/2020, 8:18 PMAdam Powell
08/31/2020, 8:18 PMGonçalo Palaio
08/31/2020, 8:19 PMColton Idle
08/31/2020, 8:50 PM