This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) { … } |
This file contains hidden or 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 | |
suspend fun MyFun() { … } | |
// lambda declaration | |
val myLambda = suspend { … } | |
// function type | |
fun MyFun(myParam: suspend () -> Unit) { … } |
This file contains hidden or 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 Messages(liveMsgs: LiveData<MessageData>) { | |
val msgs by liveMsgs.observeAsState() | |
for (msg in msgs) { | |
Message(msg) | |
} | |
} |