Skip to content

Instantly share code, notes, and snippets.

@aleweichandt
Last active Aug 17, 2021
Embed
What would you like to do?
Repository resource creation 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>>(
{ remoteSource.getAllTodos() },
{ localSource.getAllTodos() },
localSource::storeAllTodos,
localSource::deleteAllTodos,
// detached RefreshControl with 5 mins rate
RefrehsControl(TimeUnit.MINUTES.toMillis(5))
)
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment