December 2017
Intermediate to advanced
322 pages
7h 3m
English
When you're working with single or maybe, you just can't use any other blocking operator other than blockingGet(). The reason is quite simple, both monads can contain only one item.
So, let's create two new test cases by modifying the last test case as follows:
@Test fun `test Single with blockingGet`() { val observable = listOf(2,10,5,6,9,8,7,1,4,3).toObservable() .sorted() val firstElement:Single<Int> = observable.first(0) val firstItem = firstElement.blockingGet() assertEquals(1,firstItem) } @Test fun `test Maybe with blockingGet`() { val observable = listOf(2,10,5,6,9,8,7,1,4,3).toObservable() .sorted() val firstElement:Maybe<Int> = observable.firstElement() val firstItem = firstElement.blockingGet() ...Read now
Unlock full access