Hi, quick question or actually a few questions tha...
# compose
d
Hi, quick question or actually a few questions that might not be so quick. • Can you call a composable function within a SubcomposeLayout Measure Scope? • If I have a Parent Compose function with a nested Child Composable function, what is the proper way to notify the parent composable from the child? So for the first question atm I do have it calling the composable function within the SubcomposeLayout and haven't seen any issues yet, but as we all know doesn't mean that there isn't an issue. As for the second question right now Im just passing a simple callback within the child constructor and just like the first issue, it's working but is it correct? Here's a simple snippet showing the basic concept
Copy code
@Composable
fun ChildComponent(
    modifier: Modifier = Modifier,
    parentCallBack: (Boolean) -> Unit = {},     <----- is this Okay ?
    showMoreButton: @Composable (() -> Unit)? = null
    ) {
    SubcomposeLayout {
        // some logic measurement stuff

        fun addShowMoreButton(shouldShowMoreButton: Boolean, placeable: Placeable){
            parentCallBack(shouldShowMoreButton)   <------ is this Okay ?
            if (showMoreButton != null) {
                val showMoreButtonPlaceable = subcompose("showMoreButton") {
                    showMoreButton().         <------- is this Okay ?
                }[0].measure(contentConstraints)

                placeables.add(
                    showMoreButtonPlaceable to current.copy(...)
            }
        }
    }
}
Thank you again for any all feedback regarding my question.
z
yes, composing new things during measure and placement scopes is pretty much the main use case for SubcomposeLayout
d
thank you so much @Zach Klippenstein (he/him) [MOD] for the clarity. gratitude thank you