Thread
#compose
    Zhelyazko Atanasov

    Zhelyazko Atanasov

    1 year ago
    As far as I remember, a ViewModel is scoped to the first parent Fragment or Activity. In an app with a single Activity and written entirely in compose, wouldn't that result in all VMs scoped to that single Activity? Or probably I misread something 🙂
    FunkyMuse

    FunkyMuse

    1 year ago
    In compose you get ViewModels scoped to the current destination
    Zhelyazko Atanasov

    Zhelyazko Atanasov

    1 year ago
    Oh yes, now I remember - they can also be scoped to the current Nav Graph, so if you have sub-nav graphs, they'll be scoped to them.
    Manuel Vivo

    Manuel Vivo

    1 year ago
    👍
    Yeah, activities, fragments, or destinations of a nav graph
    a

    allan.conda

    1 year ago
    And possibly in the future, scoped to the composablehttps://issuetracker.google.com/issues/165642391
    Zhelyazko Atanasov

    Zhelyazko Atanasov

    1 year ago
    By the way, nice overview of Jetpack Libs & Compose in your IO talk with Ian -

    Using Jetpack libraries in Compose

    👏
    Manuel Vivo

    Manuel Vivo

    1 year ago
    Thanks 🙂
    Zhelyazko Atanasov

    Zhelyazko Atanasov

    1 year ago
    It will be nice to be able to scope a VM to a composable, but if that happens, I think it's going to be after 1.0 🙂
    Adam Powell

    Adam Powell

    1 year ago
    you can do
    CompositionLocalProvider(LocalViewModelStoreOwner provides foo) {
    same as any other
    CompositionLocalProvider
    Zhelyazko Atanasov

    Zhelyazko Atanasov

    1 year ago
    Oh nice. I'll get a closer look at the code related to all this. Thanks!