Skip to content

Instantly share code, notes, and snippets.

@StephenVinouze
Created May 13, 2020 07:07
Show Gist options
  • Save StephenVinouze/0eab00cdc36509e388d2d46fbbafb4c1 to your computer and use it in GitHub Desktop.
Save StephenVinouze/0eab00cdc36509e388d2d46fbbafb4c1 to your computer and use it in GitHub Desktop.
class PollableViewModel {
fun startPolling(): Observable<Long> =
Observable.interval(1, TimeUnit.SECONDS)
.map { it / 0 } // throws ArithmeticException: / by zero
}
class PollableView(private val pollable: PollableViewModel) {
private fun poll() {
pollable.startPolling()
.subscribe {
refreshView()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment