View Recoil.kt
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
var text by mutableStateOf("") | |
val charCount: Int get() = text.length | |
val todoList = mutableStateListOf<Item>(emptyList()) | |
val filteredTodoList get() = when (todoListFilter) { | |
Filter.Completed -> todoList.filter { it.isComplete } | |
Filter.Uncompleted -> todoList.filter { !it.isComplete } | |
Filter.All -> todoList | |
} | |
@Composable fun Example() { |
View updateScope.kt
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
$composer.end()?.updateScope { nextComposer -> | |
Counter(nextComposer) | |
} |
View Counter.kt
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 = remember($composer) { mutableStateOf(0) } | |
Button( | |
$composer, | |
text="Count: ${count.value}", | |
onPress={ count.value += 1 }, | |
) | |
$composer.end() | |
} |
View Google.kt
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 Google( | |
$composer: Composer, | |
number: Int | |
) { | |
if (number == $composer.next()) { | |
Address( | |
$composer, | |
number=number, | |
street="Amphitheatre Pkwy", | |
city="Mountain View", |
View Address.kt
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 Address( | |
$composer: Composer, | |
$static: Int, | |
number: Int, street: String, | |
city: String, state: String, zip: String | |
) { | |
Text($composer, ($static and 0b11) and (($static and 0b10) shr 1), "$number $street") | |
Text($composer, ($static and 0b100) shr 2, city) | |
Text($composer, 0b1, ", ") | |
Text($composer, ($static and 0b1000) shr 3, state) |
View Google.kt
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 Google( | |
$composer: Composer, | |
$static: Int, | |
number: Int | |
) { | |
Address( | |
$composer, | |
0b11110 or ($static and 0b1), | |
number=number, | |
street="Amphitheatre Pkwy", |
View Google.kt
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 Google(number: Int) { | |
Address( | |
number=number, | |
street="Amphitheatre Pkwy", | |
city="Mountain View", | |
state="CA" | |
zip="94043" | |
) | |
} | |
View App.kt
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 x = remember { Math.random() } | |
// ... | |
} |
View remember.kt
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 |
View filter.kt
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) } | |
// ... | |
} |
NewerOlder