-
-
Save skydoves/90cebd97fd4178946e357284afccaed5 to your computer and use it in GitHub Desktop.
user_viewmodel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UserViewModel: ViewModel() { | |
| private var mutableUsers = mutableStateListOf<User>() | |
| internal val users: StateFlow<List<User>> = MutableStateFlow(mutableUsers) | |
| } | |
| @Composable | |
| fun UserProfiles(viewModel: UserViewModel) { | |
| val users by viewModel.users.collectAsStateWithLifecycle() | |
| LazyColumn { | |
| items(users) { user -> | |
| .. | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment