I’ve compose hierarchy like below, que is NoteLis...
# compose
j
I’ve compose hierarchy like below, que is NoteListComponent is querying db unnecessarily when I goto detail and come back (because of launchedEffect) is there any way I can ignore unwanted db queries ?
Copy code
NoteListComponent(
notes: List<Note>
…coupleOfParameters
) {
    var searchText by rememberSaveable { mutableStateOf("") }

    LaunchedEffect(key1 = searchText) {
        notesViewModel.searchNotes(searchText)
    }
    LazyList(...withParams)

}
👀 1
a
Use state hoisting to VM. Keep in state: • notes List<> • searchText String • searchTextOfNotes String? // updates when notes loaded successfully In searchNotes event check searchText on equality with searchTextOfNotes to avoid redundant requests. Btw. with full state hoisting you don't need LaunchedEffect at all, just do logic inside VM's init block
j
yeh make sense
thanks I’ll try to implement this way