amar_1995
08/23/2020, 2:10 PMProvidableAmbient to pass data from screen1 to screen2. How to update data in screen2 and return back to screen1 ?Adam Powell
08/23/2020, 2:58 PMamar_1995
08/23/2020, 3:31 PMprovides() and provides to update the value butZach Klippenstein (he/him) [MOD]
08/23/2020, 4:14 PMProviders associates a value with an ambient only for children of the Providers composable. It doesn’t affect code above, before, or after itself. If screen1 and screen2 are siblings, how are you using ambients to communicate between them? The only way I could see that working is if a parent composable of both screens provided the same ambient value to both, and that value was some sort of mutable object (perhaps a MutableState) that each screen could observe and mutate independently.Adam Powell
08/23/2020, 4:17 PMprovides in a Providers(...) { } call works like to in mapOf(...)Adam Powell
08/23/2020, 4:18 PMProviders(foo provides bar) {
if (foo.current == bar) // this will be trueAdam Powell
08/23/2020, 4:18 PMval myMap = mapOf(foo to bar)
if (myMap[foo] == bar) // this will be trueAdam Powell
08/23/2020, 4:20 PMAdam Powell
08/23/2020, 4:23 PMval sharedState = remember ( MyState() }
when (sharedState.currentScreen) {
Screens.One -> Screen1(sharedState)
Screens.Two -> Screen2(sharedState)
}Adam Powell
08/23/2020, 4:24 PMMyState would offer an API that Screen1 and Screen2 can useAdam Powell
08/23/2020, 4:25 PMamar_1995
08/23/2020, 9:06 PMProviders will only work for children but we can't return data from providers in parent node of a tree ?Adam Powell
08/23/2020, 11:55 PM