blob: be48786b045ffa4ccea76960706be78529e9c76b [file] [log] [blame] [view]
Louis Pullen-Freilich14ccfcb2019-05-08 16:47:38 +01001# Compose Readme
Jim S3a6490c2019-05-07 14:10:46 -07002
3Jetpack Compose makes it easy to write and manage an application's frontend by providing a declarative API that allows users to update their Android application UI without imperatively mutating frontend views.
4
James Wardb5c6f1f2019-05-08 12:52:28 -06005A Compose application is comprised of `@Composable` functions, which are functions that transform application data into a UI hierarchy. When the underlying data changes, the Composable functions can be re-invoked to generate an updated UI hierarchy.
Jim S3a6490c2019-05-07 14:10:46 -07006
7```
8import androidx.compose.*
9import androidx.ui.core.*
10
11@Composable
12fun Greeting(name: String) {
13 Text(text = "Hello $name!")
14}
15```
16
17Compose functions should be side-effect free, and should only read data that was explicitly passed into the composable function from the caller (eg. do not read from globals).
18
19Compose is still experimental and should not be used in a production application. Furthermore, Compose requires enabling the new/experimental IR (Intermediate Representation) backend to the Kotlin compiler, so you will likely encounter language bugs related to the new backend.
20
21The compose compiler plugin makes use of some experimental extension points to the Kotlin compiler. In particular, an extension point that allows us to intercept the invocation of composable functions. You may also see some references to an XML-like syntax (known internally as KTX) which is our old syntax from before the method interception was a thing. We are transitioning from the KTX syntax to using a Kotlin DSL based on intercepted function calls.
22
Louis Pullen-Freilich14ccfcb2019-05-08 16:47:38 +010023## Feedback
24To provide feedback or report bugs, please refer to the main AndroidX contribution guide and report your bugs [here](https://issuetracker.google.com/issues/new?component=610764)
Jim S3a6490c2019-05-07 14:10:46 -070025
26