December 2017
Intermediate to advanced
322 pages
7h 3m
English
If you want to loop through all the emissions then blockingForEach is probably a better solution. It's better than blockingIterable as it will not queue up the emissions. Rather will it block the calling thread and wait for each emission to be processed before allowing the thread to continue.
In the following example, we created an Observable from a list of Int. Then applied a filter for even numbers only and then within the blockingForEach we are testing whether all the received numbers are even:
@Test
fun `test with blockingForEach`() {
val list = listOf(2,10,5,6,9,8,7,1,4,3,12,20,15,16,19,18,17,11,14,13) val observable = list.toObservable() .filter { item -> item%2==0 } observable.forEach ...Read now
Unlock full access