title: Ionic Firestore Chat-unable to constantly check for updates
body: <p>Currently, I am newbie at Ionic and I am trying to implement a chat service for an app I am working on. I wanted to try and use firestore and this is what I have so far.</p>
  
  <p>I have managed to read and receive messages from firestore but only after I send my message. </p>
  
  <p>In other words, the function to retrieve the messages only activates after I have clicked the send button. </p>
  
  <p>I was wondering if there was a way for me to constantly check firestore for updates, so that the chat can be updated in "real time".</p>
  
  <p>This is the code that I have for receiving the chat messages. I have placed them in the ionviewwilload() to receive all messages when entering the chatroom and when I click send on my messages.</p>
  
  <pre><code>retrieveCollection() : void
    {
       this._DB.getChatMessages(this._COLL,this._COLL2)
       .then((data) =&gt;
       {
          console.log(data);
          // IF we don't have any documents then the collection doesn't exist
          // so we create it!
          if(data.length === 0)
          {
            //  this.generateCollectionAndDocument();
          }
  
          // Otherwise the collection does exist and we assign the returned
          // documents to the public property of locations so this can be
          // iterated through in the component template
          else
          {
             this.chats = data;
          }
       })
       .catch();
    }
  </code></pre>
  
  <p>The getchatmessages function is then linked to my provider to then retrieve my messages from firestore before returning it as a promise.</p>
  
  <pre><code> getChatMessages(collectionObj: string, collectionObj2) : Promise&lt;any&gt;{    
      let user                : string        = firebase.auth().currentUser.uid;
      return new Promise((resolve, reject) =&gt; {
  
  
          this._DB.collection(collectionObj).doc(collectionObj2).collection("messages")
            .orderBy("sendDate", "asc")  
            .onSnapshot
            ((querySnapshot) =&gt; {
              let obj : any = [];
              querySnapshot 
              .forEach(function(doc) { 
                console.log(typeof doc);
                console.log(doc);
                obj.push({
                  id : doc.id,
                  message : doc.data().message,
                  type : doc.data().type,
                  user :doc.data().user,
                  image: doc.data().image
                });
              });
  
              resolve(obj);
            })
  
          });
        }
  </code></pre>
  
  <p>So my question is to ask if there is a special method or function that I have missed in the documentation that allows me to constantly check for updates like that in a chat app.</p>
  
  <p>Many thanks to those who reply.</p>