This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun <T> remember(vararg inputs: Any?, calculation: () -> T): T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun App(items: List<String>, query: String) { | |
val results = items.filter { it.matches(query) } | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun App($composer: Composer) { | |
val result = getData() | |
if (result == null) { | |
$composer.start(123) | |
Loading(...) | |
$composer.end() | |
} else { | |
$composer.start(456) | |
Header(result) | |
Body(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable fun App() { | |
val result = getData() | |
if (result == null) { | |
Loading(...) | |
} else { | |
Header(result) | |
Body(result) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Counter($composer: Composer) { | |
$composer.start(123) | |
var count by remember($composer) { mutableStateOf(0) } | |
Button( | |
$composer, | |
text="Count: $count", | |
onPress={ count += 1 }, | |
) | |
$composer.end() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Counter($composer: Composer) { | |
$composer.start(123) | |
var count by remember { mutableStateOf(0) } | |
Button( | |
text="Count: $count", | |
onPress={ count += 1 } | |
) | |
$composer.end() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Counter() { | |
var count by remember { mutableStateOf(0) } | |
Button( | |
text="Count: $count", | |
onPress={ count += 1 } | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Example(a: () -> Unit, b: @Composable () -> Unit) { | |
a() // allowed | |
b() // NOT allowed | |
} | |
@Composable | |
fun Example(a: () -> Unit, b: @Composable () -> Unit) { | |
a() // allowed | |
b() // allowed | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Example(a: () -> Unit, b: suspend () -> Unit) { | |
a() // allowed | |
b() // NOT allowed | |
} | |
suspend | |
fun Example(a: () -> Unit, b: suspend () -> Unit) { | |
a() // allowed | |
b() // allowed | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function declaration | |
@Composable fun MyFun() { … } | |
// lambda declaration | |
val myLambda = @Composable { … } | |
// function type | |
fun MyFun(myParam: @Composable () -> Unit) { … } |