title: RxSwift + MVVM + Coordinator Pattern, How to wait for coordinator result sequentially?
body: <p>Scenario:</p>
  
  <p>I have base coordinator which basically like so:</p>
  
  <pre><code>class Coordinator&lt;Result&gt; {
     // some coordinator class codes
  
     func coordinate(to: Coordinator&lt;T&gt;) -&gt; Observable&lt;T&gt; {
         return coordinator.start()
     }
  
     func start() -&gt; Observable&lt;Result&gt; {
        // return result
     }
  } 
  </code></pre>
  
  <p>and TestCoodinator1, TestCoordinator2, TestCoodinator3 like so:</p>
  
  <pre><code>enum Status {
      case .success(data: NSData?)
      case .cancelled(error: NSError?)
      case .failed(data: NSData?)
  }
  
  class TestCoordinator1: Coordinator&lt;Status&gt; {
       // Init pass UINavigationController as rootViewController
  
       let testVC1 = TestViewController1()
       let testVM1 = TestViewModel1()
       testVC1.viewModel = testVM1         
  
       return testVM1.status // returns Observable&lt;Status&gt;
           .do(onNext: { [unowned self] _ in self?.rootViewController.popViewController(animated: true)
  } 
  </code></pre>
  
  <p>and I have main coordinator which basically like so:</p>
  
  <pre><code>class MainCoordinator: Coordinator&lt;Void&gt; {
  
      override func start() -&gt; Observable&lt;Void&gt; {
          let mainVC = MainVC()
          let mainVM = MainVM()
          mainVC.viewModel = mainVM
  
          let testCoordinator1 = TestCoordinator1(in: rootViewController)
          let viewModel1 = ViewModel1()
          testCoordinator1.viewModel = viewModel1
  
          let testCoordinator2 = TestCoordinator2(in: rootViewController)
          let viewModel2 = ViewModel2()
          testCoordinator2.viewModel = viewModel2
  
          let testCoordinator3 = TestCoordinator3(in: rootViewController)
          let viewModel3 = ViewModel3()
          testCoordinator3.viewModel = viewModel3
  
          // viewModel.tests returns Observable that has three types of tests randomly generated
          // Observable.of("Test1", "Test2", "Test3")
          mainVM.tests ????
  
          return Observable.never()
      }
  }
  </code></pre>
  
  <p>The problem:</p>
  
  <p>How do I create observable that coordinates to test1 and wait test1 complete first, then do some processing on the result, then and only then test2 run, process some result, and then test3 run.</p>
  
  <p>If I do it like so:</p>
  
  <pre><code>mainVM.tests
     .flatMap { test in 
         switch(test) {
             case "Test1":
                   return self.coordinate(to: testCoordinator1)
             case "Test2":
                   return self.coordinate(to: testCoordinator2)
             case "Test3":
                   return self.coordinate(to: testCoordinator3)
         }
     }
     .subscribe(onNext: { status in 
        self.processStatus(status)
     })
  </code></pre>
  
  <p>all three coordinators run at the same time</p>