Thread
#compose
    amar_1995

    amar_1995

    2 years ago
    I want to show data in screen after
    onCommit
    completes. What is the suggested ways to do this ?
    Adam Powell

    Adam Powell

    2 years ago
    Can you give a bit more detail on what you're trying to do?
    generally onCommit is used for committing side effects as part of the composition. If your composition itself is changing as a direct result of something changed by an onCommit that can often indicate a code smell.
    amar_1995

    amar_1995

    2 years ago
    I am working on edit screen. I am making a server request to fetch all the datas. After fetching all the data I will show it to screen. In
    onCommit(1) {}
    block I am saving that data in local object once.
    Local object will be a
    savedInstance
    Adam Powell

    Adam Powell

    2 years ago
    so this code is requesting the data as part of the
    onCommit
    side effect and writing to the
    savedInstanceState
    object when it completes?
    amar_1995

    amar_1995

    2 years ago
    Yes
    Adam Powell

    Adam Powell

    2 years ago
    sounds fine then. If you have a suspend version of your data fetch operation things can be a little cleaner using
    launchInComposition {}
    instead of
    onCommit { onDispose {} }
    but other than that the patterns are similar
    generally you'll want to request the data from some other local object provided to your composable that can perform caching of requests and data
    and that object can be responsible for whether or not it needs to perform a network request to satisfy the request