Skip to content

Commit

Permalink
implement init from viewmodel sugestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Taqtile authored and Taqtile committed Sep 18, 2024
1 parent cbd40c2 commit ad684be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ fun UserListScreen(navController: NavHostController) {
val viewModel: UserListViewModel = viewModel()
val userPagingItems = viewModel.userList.collectAsLazyPagingItems()

LaunchedEffect(Unit) {
viewModel.loadUsers()
}

Scaffold(modifier = Modifier.padding(32.dp),
floatingActionButton = {
FloatingActionButton(onClick = { navController.navigate("NewUserScreen") }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class UserListViewModel : ViewModel() {

private val userRepository = UserRepository.getInstance()

init {
loadUsers()
}

var isLoading by mutableStateOf(false)
var userList = MutableStateFlow<PagingData<ListUserItem>>(PagingData.empty())
var loadErrorMessages by mutableStateOf(listOf<String>())
Expand Down

0 comments on commit ad684be

Please sign in to comment.