https://kotlinlang.org logo
#compose
Title
# compose
a

Adam Powell

05/20/2019, 3:06 AM
They behave as something between an object constructor and update function, and they're basically always nouns
👍 2
n

napperley

05/20/2019, 3:29 AM
In the Kotlin Coding Conventions there is a exception for factory functions. Do the Compose functions act like factory functions?
a

Adam Powell

05/20/2019, 3:31 AM
Yes, but in a rather special way since you don't get a reference to a backing object, and the system can choose to reuse/update an existing composable during a recomposition
so yes, you can think of them sort of like a factory function that can memoize/reuse objects
n

napperley

05/20/2019, 3:33 AM
In other words the Compose functions are similar enough to factory functions that the Camel Case convention makes sense.
a

Adam Powell

05/20/2019, 3:33 AM
yep
n

napperley

05/20/2019, 3:34 AM
That should be mentioned in the JetPack Compose FAQ.
2 Views