Skip to content

Instantly share code, notes, and snippets.

@teyyihan
Created October 15, 2020 14:27
Show Gist options
  • Save teyyihan/ef9a78d18d522012e27d1948b550dee2 to your computer and use it in GitHub Desktop.
Save teyyihan/ef9a78d18d522012e27d1948b550dee2 to your computer and use it in GitHub Desktop.
Dao{
@Query("SELECT * FROM users WHERE label LIKE :query")
fun pagingSource(query: String): PagingSource<Int, User>
}
ViewModel{
Pager(
config = PagingConfig(
pageSize = NETWORK_PAGE_SIZE,
),
pagingSourceFactory = { dao.pagingSource(query) }
).flow.cachedIn(viewModelScope) /* Returns a flow, you could return livedata by changing .flow to .livedata */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment