Skip to content

Instantly share code, notes, and snippets.

@Lamartio
Last active September 24, 2018 08:37
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 Lamartio/82e80b38eb2838bc5dd68aa6bf9ff76b to your computer and use it in GitHub Desktop.
Save Lamartio/82e80b38eb2838bc5dd68aa6bf9ff76b to your computer and use it in GitHub Desktop.
User.kt
data class User(val name: String = "Danny", val age: Int = 27) {
companion object {
fun asDataSource(): Observable<User> =
Observable
.interval(1, TimeUnit.SECONDS)
.scan(User()) { user, _ -> user.copy(age = user.age + 1) }
.observeOn(AndroidSchedulers.mainThread())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment