December 2017
Intermediate to advanced
322 pages
7h 3m
English
We have blockingFirst, so it's quite obvious that we would have blockingLast. As expected, it gets you the last emitted item while blocking the thread until the source emits it. The following is the code example:
@Test
fun `test with blockingLast`() {
val observable = listOf(2,10,5,6,9,8,7,1,4,3).toObservable()
.sorted()
val firstItem = observable.blockingLast()
assertEquals(10,firstItem)
}
As we are expecting the last emitted item, we are checking equality with 10.
Following is the screenshot of the testing result:

Read now
Unlock full access