State Management
Using by keyword
Section titled “Using by keyword”To use the by keyword in compose, import:
import androidx.compose.runtime.getValueimport androidx.compose.runtime.setValueManual Recompose
Section titled “Manual Recompose”var count by remember { mutableStateOf(0) }key(count){ // recompose when the var count change}snapshotFlow
Section titled “snapshotFlow”Kind of like LaunchedEffect but allows use in non-composable functions
snapshotFlow { searchQuery } .filter { it.length > 2 } // Only emit if query is longer than 2 characters .debounce(500) // Wait 500ms after last change .collect { query -> println("Search query: $query") // Example: Trigger a network search }