Skip to content

nishantpardamwar/composepaging

Repository files navigation

Using Pagination in Jetpack Compose with Room, Hilt, MVVM

This is an example to demonstrate how we can use pagination with Jetpack Compose when using Room Database with Hilt and MVVM Architecture.

Major Components Highlight

  • Jetpack Compose
  • Android Paging for compose
  • Hilt
  • MVVM

Screenshot/Gif

Compose Paging Demo Compose Paging Demo Compose Paging Demo

Compose Paging

  • PagingSource ( NotesDao.kt )

    @Query("SELECT * FROM NoteEntity")
    fun getAllNotesPaginated(): PagingSource<Int, NoteEntity>
    
  • Pager ( MainActivityViewModel.kt )

    val notePager = Pager(config = PagingConfig(10)) {
         repo.getNotePagingSource()
    }
    
  • Lazy Paging Items ( NoteListScreen.kt )

    val pager = remember { notePager }
    val lazyPagingItems = pager.flow.collectAsLazyPagingItems()
    

About

Using Paging in Compose with Room

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages