title: Usage of Snapshotlistener on a Firestore .addDocument which adds its own ID to a document
body: <p>I am creating a new document with this and add also the document id to it:</p>
  <pre><code>func createGroup(userUid: String, groupName: String, onSuccess: @escaping () -&gt; Void, onError: @escaping () -&gt; Void) {
      
      let db = Firestore.firestore()
      let dic = [&quot;groupName&quot;: groupName, &quot;userUid&quot;: userUid, &quot;timeStamp&quot;: timeStamp] as [String : Any]
       
      var ref: DocumentReference? = nil
      
      ref = db.collection(&quot;groups&quot;).addDocument(data: dic) { (error) in
          if error != nil {
              onError()
          } else {
              let docId = ref!.documentID
              print(&quot;data setted&quot;)
              ref?.setData([&quot;groupId&quot;: docId], merge: true)
              onSuccess()
              }
          }
      }
  </code></pre>
  <p>Now I have a Snapshotlistener like this to add the created data to a table view:</p>
  <pre><code>func getGroupsForAUser(userUid: String, onSuccess: @escaping (GroupsModel) -&gt; Void, onError: @escaping () -&gt; Void, onEmpty: @escaping () -&gt; Void) {
  
      let db = Firestore.firestore()
  
      db.collection(&quot;groups&quot;).whereField(&quot;userUid&quot;, isEqualTo: userUid).order(by: &quot;timeStamp&quot;, descending: true).addSnapshotListener({ (snapshot, err) in
          if err != nil {
              onError()
          } else {
              snapshot?.documentChanges.forEach { (diff) in
                  if (diff.type == .added) {
                      let dic = diff.document.data()
                      print(GroupsModel(dictionary: dic).groupId)
                      print(GroupsModel(dictionary: dic).groupName)
                      let group = GroupsModel(dictionary: dic)
                      onSuccess(group)
                      }
                  }
              }
          })
      }
  </code></pre>
  <p>The Problem: The snapshotlistener fires before &quot;ref?.setData(...)&quot; and I am missing some important information about my newly created data.</p>
  <p>How can I modify the snapshotlistener that it will be triggered after &quot;setData&quot; and not on my &quot;addDocument&quot; event?</p>