I have MyScreen Composable function. I want to loa...
# compose
g
I have MyScreen Composable function. I want to load some data from server when this screen appears. In usual android I would use
onResume()
and what I supposed to do now.
z
Probably
LaunchedTask
would be best, since it launches a coroutine that will automatically get cancelled when the function leaves the composition. If your API is callback based, you could also use
onActive
or
onCommit
with
onDispose
(soon to be renamed to
DisposableEffect
).
☝🏼 1
👍 1
a
Hey. But, i cannot use composable functions inside it, isn't?
j
z
Correct, you cannot call composable functions from “effect” functions (like
onCommit
,
*Effect
)