Created
May 21, 2019 01:50
-
-
Save objcode/c600bf47b5f801c4e014c47494ff6f3e to your computer and use it in GitHub Desktop.
Implement a one shot request with coroutines (@dao)
This file contains hidden or 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 | |
interface ProductsDao { | |
// Because this is marked suspend, Room will use it's own dispatcher | |
// to run this query in a main-safe way. | |
@Query("select * from ProductListing ORDER BY dateStocked ASC") | |
suspend fun loadProductsByDateStockedAscending(): List<ProductListing> | |
// Because this is marked suspend, Room will use it's own dispatcher | |
// to run this query in a main-safe way. | |
@Query("select * from ProductListing ORDER BY dateStocked DESC") | |
suspend fun loadProductsByDateStockedDescending(): List<ProductListing> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment