Yan Pujante
03/09/2021, 4:50 PMUserMgr.getUsers(userFilter) -> List<User>, UserMgr.removeUser(userID)
). I want to display this list of users and offer the ability to remove any item from the list (with the click of a button). I am not entirely sure how to handle this use case with compose-desktop. If I use
val userFilter = xxx
val users = remember { userMgr.getUsers(userFilter) }
// ...
// for each user
val id = ...
Button(onClick = { userMgr.delete(id) } // ...
// ...
Then of course it does not get recomposed because there is no way for the framework to know that the list has changed... I apologize if this question has been asked before. Can somebody point me to the recommended way to handle a compose-dekstop application backed by a database with essentially screens that implement CRUD access to it?theapache64
03/09/2021, 5:57 PMViewModel
layer between View
and Data
source and I'd store the users
in a StateFlow
(inside ViewModel
). Then on each create/update/delete
, I'd also update the users
list.
on the view layer, I'd use collectAsState
(inside @Composable
function)theapache64
03/09/2021, 6:00 PMrnett
03/09/2021, 8:58 PMusers
a StateList (or whatever the real version is called) and remove the removed user from it.