Skip to content

Instantly share code, notes, and snippets.

@luks91
Last active October 16, 2017 12:55
Show Gist options
  • Save luks91/e6f454acd80589ee35f0aa903cb4c71b to your computer and use it in GitHub Desktop.
Save luks91/e6f454acd80589ee35f0aa903cb4c71b to your computer and use it in GitHub Desktop.
fun statefulIntegers() = Flowable.generate(
Callable<Int> { 0 },
BiFunction<Int, Emitter<Int>, Int> { index, emitter ->
if (index < 100) {
emitter.onNext(index)
} else {
emitter.onComplete()
}
return@BiFunction index + 1
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment