title: Is it possible to create a serial queue across multiple ViewControllers in swift
body: <p>I have a series of <code>ViewControllers</code> which each are uploading data to <code>Firebase</code>. I would like to know is if it is possible to create a serial queue which would ensure that they are uploading in the order that the view controllers are displayed. Would I have to create a delegate method to do something like this?</p>
  
  <p>My <code>ViewController</code>s look like the following</p>
  
  <p>VC 1:</p>
  
  <pre><code>class VC1: UIViewController{
  
     func nextVC(_ data: Data){
        db.collection("collection")
          .document("Document").setData([
             "data1": data
          ]){ err in
             if let err = err {
                print("Error writing document: \(err)")
             } else {
                print("Document successfully written!")
             }
         }
         self.performSegue(withIdentifier: K.firstSegue, sender: self)
     }
  }
  </code></pre>
  
  <p>VC 2:</p>
  
  <pre><code>class VC2: UIViewController{
  
     func nextVC(_ data: Data){
        db.collection("collection")
          .document("Document").updateData([
             "data2": data
          ]){ err in
             if let err = err {
                print("Error writing document: \(err)")
             } else {
                print("Document successfully written!")
             }
         }
         self.performSegue(withIdentifier: K.secondSegue, sender: self)
     }
  }
  </code></pre>
  
  <p>VC 3:</p>
  
  <pre><code>class VC3: UIViewController{
  
     func nextVC(_ data: Data){
        db.collection("collection")
          .document("Document").updateData([
             "data3": data
          ]){ err in
             if let err = err {
                print("Error writing document: \(err)")
             } else {
                print("Document successfully written!")
             }
         }
     }
  }
  </code></pre>
  
  <p><strong>EDIT: for clarification</strong></p>
  
  <p>The issue that I was having was that when I got to my third view controller I would get an error that the document I was trying to update did not exist. I thought that by adding all three <code>Firebase</code> calls to a <code>DispatchQueue</code> I could avoid this issue. This did work but I then had an issue with lag time between view controllers. What I am hoping is for the <code>ViewControllers</code> to add their data to a queue to upload to <code>Firebase</code> serially so that they up load in the proper order and for that to take place in the background so that it does not impact the UI.</p>