title: synchronize async network calls with RxSwift
body: <p>I am using Facebook to authenticate users. This process happens async. After this is complete i have to authenticate user through firebase, which happens async. Even though I am using RxSwift, I end up nesting async tasks just as if i were to use callbacks and end up with callback hell .</p>
  
  <p>My current procedure just doesn't seem right. Kinda hard to read also. Is it me or is there a more elegant approach to handling multiple async network calls.  </p>
  
  <p>for this example I took out the error events because it makes the code even less readable. </p>
  
  <p>Thanks for any tips or guidance.</p>
  
  <pre><code>func rx_login(viewController: UIViewController) {
  
      /// Facebook login
      rx_facebookLogin(viewController: viewController)
          .asObservable()
          .subscribe(onNext: { [weak self] (credentials: AuthCredential, userInfo: [String: Any]) in
  
              /// Firebase Login
              rx_firebaseLogin(with: credentials)
                  .asObservable()
                  .subscribe(onNext: { [weak self] (uid) in
  
                      /// TODO: Save user info firebase db
  
  
                  }).addDisposableTo(disposeBag)
  
          }).addDisposableTo(disposeBag)
  </code></pre>