Makes effects in composables more declarative#878
Conversation
| LaunchedEffect(uiState.isTaskSaved) { | ||
| if (uiState.isTaskSaved) { | ||
| onTaskUpdate() | ||
| if (uiState.isTaskSaved) { |
There was a problem hiding this comment.
Would this run on every recomposition, regardless of if uiState.isTaskSaved changed or not?
There was a problem hiding this comment.
Maybe this is answered here: https://stackoverflow.com/questions/69085027/difference-between-remember-and-rememberupdatedstate-in-jetpack-compose
There was a problem hiding this comment.
Yeah. This if statement will be check on every recomposition
| LaunchedEffect(uiState.isTaskSaved) { | ||
| if (uiState.isTaskSaved) { | ||
| onTaskUpdate() | ||
| if (uiState.isTaskSaved) { |
There was a problem hiding this comment.
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.
No description provided.