Utkarsh Tiwari
04/12/2021, 1:42 PMUtkarsh Tiwari
04/12/2021, 1:42 PM@Composable
fun ComposableB(
content: @Composable LazyListScope.() -> Unit
) {
LazyRow { // edit
content()
}
}
@Composable
fun LazyListScope.ComposableA() {
val items = listOf(...)
itemsIndexed(
items = trimmedList,
itemContent = { index, item ->
}
)
}
ComposableB {
ComposableA() // Should only be allowed within this composable
}
Alex
04/12/2021, 1:45 PMcontent
method and make ComposableA()
an extension function on that scope object.
e.g. something like:
object ComposableBScope
@Composable
fun ComposableBScope.ComposableA(){ ... }
@Composable
fun ComposableB(
content: @Composable ComposableBScope.() -> Unit
) {
content(ComposableBScope)
}
Alex
04/12/2021, 1:46 PMComposableBScope.ComposableA()
anywhere, but there are ways of restricting it more narrowlyUtkarsh Tiwari
04/12/2021, 1:50 PMAlex
04/12/2021, 1:52 PM@Composable
fun ComposableBScope.ComposableA(lazyListScope: LazyListScope) {
Alex
04/12/2021, 1:53 PMComposableBScope
as this
and LazyListScope
as it