title: How to retrieve data synchronously from Firebase?
body: <p>I have two collections namely, Users and Questions.</p>
  
  <p>Based on the user logged in using userId, I retrieve the <code>currQuestion</code> value from <code>users</code> collection.</p>
  
  <p>Based on the <code>currQuestion</code> value, I need to retrieve the <code>question</code> document from Firebase <code>Questions</code> collection.</p>
  
  <p>I've used the below code to retrieve userId</p>
  
  <pre><code>rootRef.child("0").child("users")
          .queryOrderedByChild("userId")
          .queryEqualToValue("578ab1a0e9c2389b23a0e870")
          .observeSingleEventOfType(.Value, withBlock: { (snapshot) in
  
              for child in snapshot.children {
                  self.currQuestion = child.value["currentQuestion"] as! Int
              }
              print("Current Question is \(self.currQuestion)")
  
              //print(snapshot.value as! Array&lt;AnyObject&gt;)
          }, withCancelBlock : { error in
                  print(error.description)
          })
  </code></pre>
  
  <p>and to retrieve question </p>
  
  <pre><code>rootRef.child("0").child("questions")
  .queryOrderedByChild("id")
  .queryEqualToValue(currQuestion)
  .observeSingleEventOfType(.Value, withBlock: { (snapshot) in
              for child in snapshot.children {
                  print(child.value["question"] as! String)
              }
  
              }, withCancelBlock: { error in
                  print(error.description)
          })
  </code></pre>
  
  <p>But the above code executes asynchronously. I need to solution to make this synchronous or how to implement listeners so I can fire back the question query once the <code>currQuestion</code> value is changed?</p>