Thread
#compose
    Grigorii Yurkov

    Grigorii Yurkov

    1 year ago
    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.
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    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
    ).
    a

    alorma

    1 year ago
    Hey. But, i cannot use composable functions inside it, isn't?
    Jeremy

    Jeremy

    1 year ago
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    Correct, you cannot call composable functions from “effect” functions (like
    onCommit
    ,
    *Effect
    )