Last active
May 21, 2021 07:47
-
-
Save adityawid/374812046a7166e23081e8e094093efe to your computer and use it in GitHub Desktop.
This file contains 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
private val adapter: MoviePagingAdapter by lazy { | |
MoviePagingAdapter() | |
} | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
initObservers() | |
} | |
fun initObservers() { | |
/** | |
Gunakan ini jika menggunakan liveData | |
*/ | |
// viewModel.favMoviesasLiveData.observe(viewLifecycleOwner, { | |
// adapter.submitData(viewLifecycleOwner.lifecycle, it) | |
// }) | |
/** | |
Gunakan ini jika menggunakan flow | |
*/ | |
lifecycleScope.launch { | |
viewModel.favMoviesasFlow.collectLatest { | |
adapter.submitData(it) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment