`LaunchedEffect(key1 = true) { sharedViewMo...
# coroutines
c
LaunchedEffect(key1 = true) {        sharedViewModel.getAllTasks()    }
val allTasks by sharedViewModel.allTasks.collectAsState()
This is from Stevdza's course. How can he be sure that getAllTasks() will have completed (fetched all tasks from room) before the second line.
j
I don't know much about Compose, but using
by
means that
allTasks
property access will be delegated, so
getAllTasks()
doesn't need to be completed before that line from what I can see here.
👍 1
c
I think it has to do with the sharedViewModel.allTasks being StateFlow, so it'll update allTasks in composable after it actually retrivies data from room. Thanks for answering.