~/talk

Avoiding common coroutines mistakes in Compose

Talkat KotlinConf 2023 · 2023-04-12..04-14· Veilingzaal· [android]
slides:none on file

Compose code repeatedly launches coroutines when those launches live directly inside composable bodies, causing a snackbar to pop endlessly if recomposition happens every second; the fix is to use LaunchedEffect with keys instead of ad hoc rememberCoroutineScope launches. Creating a flow inside composition restarts it on every recomposition so the pizza loader animation resets unless the flow is remembered across recompositions. UI observing a StateFlow sees no updates until it uses collectAsStateWithLifecycle (or collectAsState) so live prices actually update.

AI-written summary · about

  1. 0:00Intro
  2. 2:31Composable functions can...
  3. 5:03Creating coroutines in the composition
  4. 7:23A positive example
  5. 8:59Creating Flows in the composition
  6. 11:39Using StateFlow values
  7. 13:56Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.