Kshitij Patil12/04/2020, 3:24 PM
in it? Do I get a snapshot of snapshot of state and won't receive any further updates or will do? I've a navigation graph definition using navigation-compose and am using different viewModel for each of its screens. I'm doing
in the content parameter of
extension function. I want the respective Composable in the navgraph to be notified on any state changes in its associated viewModel. I checked every step in the process of mutating the state and viewModel state is working properly but the Composable is not listening to these changes and thus not being updated. How should this be achieved in general? Individual Composables listening to their own ViewModels when they're part of some navigation hierarchy like BottomNavigation ?
Adam Powell12/04/2020, 3:34 PM
collects the flow and writes into the state object. Compose sees the state changes and recomposes. Can you post the code that is behaving unexpectedly?
Kshitij Patil12/04/2020, 4:12 PM
Joost Klitsie12/05/2020, 7:22 AM
Kshitij Patil12/05/2020, 8:18 AM
and then I distributed the respective fields to composables in navgraph assuming that only those composables will be notified when respective field is changed. However, since the Composable itself was taking in the state, it turned out to be recomposed on any field changes. Instead of passing in state, I kept that at parent Composable only and used "slots" to write individual pages and passed in respective state fields directly into those slots. This way, only associated pages got recomposed and everything just worked. But, since I moved large chunk of code from the NavHost to parent itself in the form of slots, it resulted in verbose code in the same file.