Feature description
Parent-child communication is one of the ways to implement communication between screen.
It also can provide flexibility by implementing inversion of control principle, when child doest interacts directly with a parent but provides some set of methods, that parent can interact with.
Common case scenario is when you want to be able to:
- Observe your children state, to modify your own state. Usecases:
- Enables button in your parent only if child screen is ready for continue.
- Triggering some action, f.e. reloading a page.
Challenges
Since our ViewModels are defined in @Composable fun we unable to have direct access to it. There are 2 probably solutions:
- When we need to interact with
ViewModel having only Screen instance, we can try to find ViewModel in our Store and if there is no ViewModel yet - define some default behaviour on client side.
- Provide the ability to store a
ViewModel (or any other object) as a property of Screen.
Tasks
Feature description
Parent-child communication is one of the ways to implement communication between screen.
It also can provide flexibility by implementing inversion of control principle, when child doest interacts directly with a parent but provides some set of methods, that parent can interact with.
Common case scenario is when you want to be able to:
Challenges
Since our ViewModels are defined in
@Composable funwe unable to have direct access to it. There are 2 probably solutions:ViewModelhaving onlyScreeninstance, we can try to findViewModelin our Store and if there is noViewModelyet - define some default behaviour on client side.ViewModel(or any other object) as a property ofScreen.Tasks