Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.69 KB

README.md

File metadata and controls

38 lines (26 loc) · 1.69 KB

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()