If I have a composable function `Foo` that returns...
# compose
e
If I have a composable function
Foo
that returns a
Bar
and it gets called from
Baz
, if
Foo
needs to recompose does
Baz
recompose?
s
Sounds like a yes. But you could probably throw some code here to make more clear what you are describing.
e
Yeah, quickly threw it out there because I was about to go to sleep đŸ˜… I'm thinking something like
Copy code
@Composable
fun Foo(): Bar{
  return vm.barFlow().collectAsState().value
}

@Composable
fun Baz() {
  val bar = Foo()
  // do something with bar
}
s
Yes, Baz will receive the new value from Foo(), and it will recompose. With that said, composable functions that return something should be lower-case to indicate that. So since your
Foo
returns a value, i should be called
foo
. Also it may be a good idea to return
State<Bar>
instead of doing the
value
read in the function itself, so that on the call site you can read it as a state and only use it later at the point that it is needed instead of the entire recomposition scope of
Baz
, but that’s a minute detail tbh.