Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Created October 2, 2022 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skyyo/9ee1d95f807f4725a930c57552b92ef8 to your computer and use it in GitHub Desktop.
Save Skyyo/9ee1d95f807f4725a930c57552b92ef8 to your computer and use it in GitHub Desktop.
perf_snippet_8
@Composable
fun UnstableLambdaScreen(viewModel: TypicalViewModel = hiltViewModel()) {
val focusRequester = LocalFocusManager.current
val onNameEnteredClick: (value: String) -> Unit = remember {
return@remember viewModel::onNameEntered
}
val clearFocus = remember { { focusRequester.clearFocus() } }
Column {
// stable lambdas, skippable button
Button(onClick = {
onNameEnteredClick("..")
clearFocus()
someTopLvlFunction()
}) {
Text(text = "button with stable lambdas")
}
}
}
// top lvl functions without unstable params are stable
fun someTopLvlFunction() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment