Hey everyone is `LaunchedEffect`'s block executed together with composition phase, or after the composition phase is completed? I saw in the official docs,
SideEffect
is executed after the composition is completed, can't find the same info for
LaunchedEffed
.
Copy code
LaunchedEffect(messages, lazyListState) {
// In this block can I assume that "messages" and "lazyListState" are synced? Has "lazyListState" already had the info of current "messages"' items, such as itemCount,...
}
s
Stylianos Gakis
03/11/2024, 2:02 PM
LaunchedEffect in any case launches a coroutine, which won’t run in the same frame as the first composition. Even what you do in there is not anything that is suspending itself
Stylianos Gakis
03/11/2024, 2:03 PM
If either of those two keys change the old effect will just be cancelled and a new one will be scheduled to run, is that what you are worried about here?
👍 1
s
Son Phan
03/12/2024, 4:30 AM
This is basically what I am worried
Copy code
LaunchedEffect(messages, lazyListState) {
// In this block can I assume that "messages" and "lazyListState" are synced? Has "lazyListState" already had the info of current "messages"' items, such as itemCount,...
}
s
Stylianos Gakis
03/12/2024, 7:44 AM
I'm still not sure what you're worried about, I replied about this right above.
You can run the app and log what you get in there to see what exactly you'll be seeing.