Skip to content

Instantly share code, notes, and snippets.

@LloydBlv
Created June 7, 2024 07:19
Show Gist options
  • Save LloydBlv/b24286abd5a3e8bece3f12055cf550c9 to your computer and use it in GitHub Desktop.
Save LloydBlv/b24286abd5a3e8bece3f12055cf550c9 to your computer and use it in GitHub Desktop.
// In a Fragment
class UserFragment : Fragment() {
private val userViewModel: UserViewModel by viewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val userId = "12345" // Get this from arguments or somewhere else
userViewModel.fetchUserData(userId) // Called from Fragment
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment