Skip to content

Conversation

manuelvicnt
Copy link
Contributor

No description provided.

LaunchedEffect(uiState.isTaskSaved) {
if (uiState.isTaskSaved) {
onTaskUpdate()
if (uiState.isTaskSaved) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this run on every recomposition, regardless of if uiState.isTaskSaved changed or not?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This if statement will be check on every recomposition

LaunchedEffect(uiState.isTaskSaved) {
if (uiState.isTaskSaved) {
onTaskUpdate()
if (uiState.isTaskSaved) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using recomposition as an observer of state change events to apply other changes to app state. Avoid this. Observe the state changes inside the LaunchedEffect instead so that it doesn't take one recomposition pass to apply currentOnTaskUpdate and then another to apply changes caused by that call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants