Created
October 2, 2022 13:35
-
-
Save Skyyo/9ee1d95f807f4725a930c57552b92ef8 to your computer and use it in GitHub Desktop.
perf_snippet_8
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 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