我想每 5 秒呼叫一次我的 ViewModel 函式。在 Jetpack Compose 中做到這一點的最佳方法是什么?
uj5u.com熱心網友回復:
這取決于您希望此行為何時開始和結束。
只要您的可組合檔案仍在組合中,這就會運行:
LaunchedEffect(Unit) {
while(true) {
vm.someMethod()
delay(5000)
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/364485.html
