Skip to content

Instantly share code, notes, and snippets.

@aleweichandt
Created August 17, 2021 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleweichandt/a404c58c70de1df7ba2b987adbaa5c3a to your computer and use it in GitHub Desktop.
Save aleweichandt/a404c58c70de1df7ba2b987adbaa5c3a to your computer and use it in GitHub Desktop.
Query migration example
class TodoRepository(
private val localSource: ITodoCache, // Cache injection
private val remoteSource: ITodoApi
) {
// new resource to query List<Todo>
private val todoResource: Resource<Unit, List<Todo>>
// migrate call to use resource
// before was like: remoteSource.getAllTodos()
suspend fun getAllTodos(force: Boolean): Flow<List<Todo>?> =
resourceGroup.query(Unit, force)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment