Created
October 15, 2020 14:27
-
-
Save teyyihan/ef9a78d18d522012e27d1948b550dee2 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
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