There is `setViewContent` which accept composable ...
# compose
a
There is
setViewContent
which accept composable function as input parameter similar to
setContent
. So I want know what is a diference between
setViewContent
and
setContent
and its use-cases. And my second question is that
setContent
and
setViewContent
both return
CompositionContext?
. So what is the usage of CompositionContext ?
l
Good question. Right now the primary way to use compose is by using the composables defined in
androidx.ui.*
. We call this “compose UI”. This uses compose runtime to target a tree of `ComponentNode`s. One can also use compose runtime to target a tree of `View`s. Right now,
setViewContent
is used for the latter, and
setContent
for the former. We are investigating different ways to switch between the two, but exactly how this will work is still being decided. Similarly, the exact shape of these functions may change, and the return value as well. Right now the return value is mostly used in testing. Using it is largely an “advanced usage” area and the exact API we expose on CompositionContext is likely to change pretty significantly, but you rarely need it, so i wouldn’t worry about it for now 😉