Skip to content

Instantly share code, notes, and snippets.

@exallium
Created January 5, 2017 19:57
Show Gist options
  • Select an option

  • Save exallium/3d63b204d8c005dd1bd973c81553a5df to your computer and use it in GitHub Desktop.

Select an option

Save exallium/3d63b204d8c005dd1bd973c81553a5df to your computer and use it in GitHub Desktop.
Infinite Rx Sequence Usage
@Test
fun rx_infinite() {
val testSub = TestSubscriber<Int>()
var start = 0
fun inc(): Int {
start += 1
return start
}
Observable.just(1).repeat().flatMap {
Observable.just(inc())
}.take(4).subscribe(testSub)
testSub.assertCompleted()
testSub.assertValueCount(4)
testSub.assertValues(1, 2, 3, 4)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment