https://kotlinlang.org logo
Title
g

GeorgeS-Litesoft

01/28/2022, 3:17 PM
New to Compose, but have done AWT, Swing, GWT, Web (of course), and interested in Fyne (GoLang), JavaFX. In the ones I've actually used, each "component" could access the "parent component" (walk the directed graph, e.g. DOM), is that possible with compose?
n

nitrog42

01/28/2022, 3:23 PM
no (at least not that I know), it is explained here : https://developer.android.com/jetpack/compose/mental-model#paradigm
a

Adam Powell

01/28/2022, 4:13 PM
Generally if a parent wants to make its own services available to child components, it should pass those dependencies to children as explicit parameters rather than having the children query parents for them
the characteristics of lambda capture often make explicit dependency parameters across layers unnecessary
n

nitrog42

01/28/2022, 4:22 PM
an example here with scrollable : https://developer.android.com/jetpack/compose/gestures#scroll-modifiers the parent makes a
val state = rememberScrollState()
that it can pass to childs, so they can scroll to a certain point of the page for example