GithubHelp home page GithubHelp logo

scopeinvestment's Introduction

phone rotation navigating to another screen
LaunchedEffect cancelled cancelled
rememberCoroutineScope() cancelled cancelled
viewModelScope Job keeps running until finished Job keeps running until finished
  • LaunchedEffect and rememberCoroutineScope() are attached to the composable lifecycle. The jobs will be cancelled if the composable leaves its composition.
  • viewModelScope is attached to the ViewModel lifecycle. The jobs will be cancelled if the viewModel is cleared.

Composable Lifecycle

image

  • Configuration changes and navigating to another screen can let the composable leave the composition.
  • See Lifecycle of composables.

ViewModel Lifecycle

  • A ViewModel, including the one returned by viewModel(), is scoped to either an Activity or Fragment, not the Composable where viewModel() was called. See viewModel.
  • See viewModel for the following statement.

Note: Due to their lifecycle and scoping, you should access and call ViewModel instances at screen-level composables, that is, close to a root composable called from an activity, fragment, or destination of a Navigation graph. You should never pass down ViewModel instances to other composables, pass only the data they need and functions that perform the required logic as parameters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.