Skip to content

Instantly share code, notes, and snippets.

@luks91
Created November 24, 2017 17:15
Show Gist options
  • Select an option

  • Save luks91/f512e7ad2cbc6261db889d13f884d44a to your computer and use it in GitHub Desktop.

Select an option

Save luks91/f512e7ad2cbc6261db889d13f884d44a to your computer and use it in GitHub Desktop.
data class Credentials(val username: String, val password: String)
interface ContactsApi {
fun getContacts(credentials: Credentials): Flowable<SimpleContact>
companion object {
fun createFor(serverUrl: String) = object: ContactsApi {
override fun getContacts(credentials: Credentials):
Flowable<SimpleContact> {
Log.i("ContactsApi",
"Querying for contacts from $serverUrl with $credentials")
return Flowable.just(
SimpleContact("Contact1", isStarred = false),
SimpleContact("Contact2", isStarred = false),
SimpleContact("Contact3", isStarred = true)
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment