Skip to content

Instantly share code, notes, and snippets.

@talosdev
Created October 6, 2019 16:46
Show Gist options
  • Select an option

  • Save talosdev/54d8a9f5af7ed369abb5be26ddd1d2ab to your computer and use it in GitHub Desktop.

Select an option

Save talosdev/54d8a9f5af7ed369abb5be26ddd1d2ab to your computer and use it in GitHub Desktop.
@Test
fun `hot observable to single with firstOrError`() {
val observable = Observable.fromIterable<Int>((1..5).toList())
.doOnNext { println("Source observable emitting $it") }
.publish()
val single = observable.firstOrError()
.doOnSuccess { println("Single succeeded with value: $it") }
val testObserver = single.test()
observable.connect()
testObserver.await()
testObserver.apply {
assertComplete()
assertValue(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment