David W
12/03/2021, 11:30 PMrefreshScope = CoroutineScope(Job())
refreshScope.launch(Dispatchers.Default) {
println("Clicked Refresh button pntln.")
}
but this produces text?
refreshScope = CoroutineScope(Job())
refreshScope.launch(<http://Dispatchers.IO|Dispatchers.IO>) {
println("Clicked Refresh button pntln.")
}
The only difference is the Dispatcher (IO works, Default doesn't).
The issue is somewhere else in my code, I expect, and there's far too much to include; both code snippets work in a vacuum. I'm just hoping for a direction to start looking.Joffrey
12/03/2021, 11:40 PMJoffrey
12/03/2021, 11:40 PMNick Allen
12/03/2021, 11:43 PMJoffrey
12/03/2021, 11:45 PMNick Allen
12/04/2021, 12:18 AMGlobalScope.launch(Dispatchers.Default) { someStateFlow.collect { yield(1000) } }
This is not:
GlobalScope.launch(Dispatchers.Default) { someStateFlow.collect { Thread.sleep(1000) } }
David W
12/04/2021, 12:33 AMDavid W
12/04/2021, 12:37 AMDavid W
12/04/2021, 12:39 AM@Composable
private fun AppState.refreshButton() {
val refreshScope by remember { mutableStateOf(CoroutineScope(Job())) }
TooltipArea(
tooltip = { SmolTooltipText(text = "Refresh modlist & VRAM impact") }
) {
Button(
onClick = {
Timber.d { "test." }
refreshScope.launch(Dispatchers.Default) {
Timber.d { "Clicked Refresh button." }
// reloadMods()
}
},
modifier = Modifier.padding(start = 16.dp)
) {
Icon(
painter = painterResource("refresh.svg"),
contentDescription = "Refresh",
tint = SmolTheme.dimmedIconColor()
)
}
}
}
When you click the button, "test." prints, but the launch
inside the click handler doesn't fireNick Allen
12/04/2021, 12:48 AMDavid W
12/04/2021, 12:52 AMDavid W
12/04/2021, 12:57 AMDavid W
12/04/2021, 1:10 AMrefreshScope.launch(Dispatchers.Default) {
Timber.d { "Clicked Refresh button." }
reloadMods()
Timber.d { "Finished reloading mods 2." }
}
The second debug line is never hitDavid W
12/04/2021, 2:08 AMDavid W
12/04/2021, 2:09 AMDavid W
12/04/2021, 2:09 AMDavid W
12/04/2021, 2:09 AMwhile(isActive)
loopDavid W
12/04/2021, 2:10 AMdelay
and no yield
David W
12/04/2021, 2:11 AMDavid W
12/04/2021, 2:11 AMDavid W
12/04/2021, 2:22 AMDavid W
12/04/2021, 2:23 AMJoffrey
12/04/2021, 2:24 AM