1

I have a chaining operation in my application, Where i have a list of some data, i will iterate through the list with iteratable observable once the iteration completes, i will perform some other operation which does not depends on the previous list, so what i need is in between these two operation i need to block(or barrier) until the first completes and proceed with second one.

Example

Observable.fromIterable(listOf("A","B","C","D"))
          .map{
            doSomeTask(it)
          } 
   // I need a blocking here, once this iteration completes i will proceed with the below task, but i don't need of toList() to block since i don't want the data,       
          .map{
            doSomeOtherTask()
          }

Can anyone help me out with this ?

Stack
  • 1,164
  • 1
  • 13
  • 26

2 Answers2

0

Use doOnNext if you want to propagate each of the values, or doOnComplete when you want to do something at the end of the iteration.

Tassos Bassoukos
  • 16,017
  • 2
  • 36
  • 40
0

What you could do is below:

Observable.fromIterable(listOf("A", "B", "C", "D"))
        .subscribeBy(
            onNext = {
                doSomeTask(it)
            },
            onComplete = {
                doSomeOtherTask()
            }
        )

This way you'll achieve the expected result. Cheers!

r2rek
  • 2,083
  • 13
  • 16