Is there any way indirect children `Modifier` pass...
# compose
n
Is there any way indirect children
Modifier
pass data to the grand-parent composable? I want to pass data without involving
ModifierLocal
. I have custom modifier that implements
ParentDataModifier
or
ParentDataModifierNode
. The function that creates this modifier is belonging to a scope
MyScope
. If the composables are direct children of my custom layout composable, then I'm able to read the
parentData
of the
Measurable
in the
layout(...) {    }
block. That works fine. This is the code when the composable is direct descendant and I'm able to read out `parentData`:
Copy code
@Composable
fun MyScreen(...){
   MyCustomLayout(....){ // here is MyScope context
     //direct child
     Button(modifier = Modifier.message("This should be read in layout phase"))
   }
I want to achieve reading data from composables that indirect descendant of my custom layout composable, yet they are within
MyScope
Copy code
@Composable
fun MyScreen(...){
   MyCustomLayout(....){ // here is MyScope context
     //direct child
      Box{
          //indirect child
          Button(modifier = Modifier.message("This should be read in layout phase"))
      }
   }
I also followed discussion here , that seems to have the same problem.
e
> I want to … read… (parent) data from composables that (are) indirect descendants of my custom layout composable This is not possible unfortunately. What exactly are you trying to achieve?
n
I'm aware it isn't possible because layout is happening in each composable node separately. That being said, a
Measurable
is a single descendant that has it's own layout phase. I'm asking if there is other way that I might have overlooked or haven't thought of. As stated in the body, I'm trying to pass data from indirect child to a top-parent through
parentData
(
ParentDataModifier
)