Skip to content

Instantly share code, notes, and snippets.

@ragdroid
Created February 21, 2018 08:29
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 ragdroid/1df088ab5789950fe69cc37971b482e3 to your computer and use it in GitHub Desktop.
Save ragdroid/1df088ab5789950fe69cc37971b482e3 to your computer and use it in GitHub Desktop.
Cache Interface to talk to the whole app
interface DataStore<T> {
fun modelListObservable(): Maybe<List<T>>
fun modelObservable(id: String): Maybe<T>
fun putModels(vararg models: T)
fun clear()
fun modelObservable(): Maybe<T>
= modelListObservable().map {
list -> list.get(0)
}
val isDataAvailableObservable: Single<Boolean>
get() = modelObservable().isEmpty
.map { !it }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment