Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class FeedViewModel : ViewModel(), KoinComponent {
private val repo: PostRepository by inject()
fun getFeeds(): Observable<PagedList<Post>> = repo.getFeeds()
class FeedActivity : BaseActivity() {
private lateinit var list: RecyclerView
private val adapter = FeedAdapter()
private val viewModel by viewModel<FeedViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
list.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)
list.adapter = adapter
.subscribe {
}.apply { addDisposable(this) }
class FeedAdapter : PagedListAdapter<Post, RecyclerView.ViewHolder>(PostDiffUtils) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
// create view holder as same as you do in RecyclerView.Adapter
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
// bind data as same as you do in RecyclerView.Adapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.