title: handle nested observables in RxSwift
body: <p>I'm trying to combine facebook login with a rest call, so when the user is logged in it should make an authenticate call to the server, where the server makes the graph calls, however I'm a bit confused to how I nest the calls with RxSwift? so far I have a FacebookProvider class with following method</p>
  
  <pre><code>func login() -&gt; Observable&lt;String&gt; {
      return Observable.create({ observer in
  
          let loginManager = LoginManager()
  
          //LogOut before
          loginManager.logOut()
  
          //Set Login Method
          loginManager.loginBehavior = .native
  
          //Login Closure
          loginManager.logIn([ .publicProfile, .userFriends, .email], viewController: self.parentController) { loginResult in
              switch loginResult {
              case .failed(let error):
                  print(error)
                  observer.onError(FacebookError.NoConnection(L10n.networkError))
              case .cancelled:
                  print("User cancelled login.")
              case .success(_, let declinedPermissions, let accessToken):
                  print("Logged in!")
  
                  guard declinedPermissions.count &gt; 0 else {
                      observer.onError(FacebookError.DeclinedPermission(L10n.declinedPermission))
                      return
                  }
  
                  observer.onNext(accessToken.authenticationToken)
                  observer.onCompleted()
  
              }
          }
  
  
          return Disposables.create()
      })
  
  }
  </code></pre>
  
  <p>Then I have a <code>LoginViewModel</code> with this model</p>
  
  <pre><code>public func retrieveUserData() -&gt; Observable&lt;User&gt; {
      return Network.provider
                  .request(.auth(fbToken: Globals.facebookToken)).retry(5).debug().mapObject(User.self)
  }
  </code></pre>
  
  <p>then I in my <code>UIViewController</code> do this</p>
  
  <pre><code>    facebookProvider.validate().subscribe({ [weak self] response in
  
          switch response {
          case .error(_):
              // User is not logged in push to loginController
              break
  
          case .next():
              //user is logged in retrieveUserData before proceeding
  
              self?.loginViewModel.retrieveUserData().subscribe { event in
                  switch event {
                  case .next(let response):
                      print(response)
                  case .error(let error):
                      print(error)
                  case .completed:
                      print("completed")
                  }
              }.addDisposableTo(self?.disposeBag)
  
  
              break
          case .completed:
              //data is retrieved and can now push to app
              break
  
  
          }
  
      }).addDisposableTo(disposeBag)
  </code></pre>
  
  <p><strong>Validate</strong></p>
  
  <pre><code>public func rx_validate() -&gt; Observable&lt;String&gt; {
      return Observable.create({ observer in
          //Check if AccessToken exist
          if AccessToken.current == nil {
              observer.onError(FacebookError.NotLoggedIn)
          } else {
              observer.onNext(Globals.accessToken)
          }
          observer.onCompleted()
          return Disposables.create()
      })
  }
  </code></pre>