title: Why 'onSnapshot' google firebase is so fast, instantly fired?
body: <p>I build a simple react app to test google firebase. Anyone have any idea how the <code>onSnapshot</code> method works? I mean, it is so fast (like, instantly), even when I change network to slow 3G in devtools, it still fast. I noticed in XHR tab, when the app made request to firebase, request is still pending, but <code>onSnapshot</code> already fired and change the state in my react app. I thought it will wait until there's response from firebase, but that's not the case.</p>
  
  <pre><code>.firestore()
    .collection("expense")
    .onSnapshot((snapshot) =&gt; {
      const newExpense = snapshot.docs.map((doc) =&gt; {
        return {
          id: doc.id,
          ...doc.data(),
        };
      });
  
      //set state is fired, but request is still pending
      this.setState({expense: newExpense});
    });
  </code></pre>
  
  <p>Did firebase just store the app state somewhere, or just simply read the app state and then update the state (call <code>onSnapshot</code>) when making request? If that's the case then you can not handle network error (or you can but that would be weird), because the app state is already changed.</p>
  
  <p>Did firebase update the app state when this function (function below is to add collection to firebase database) called? and didn't even wait until request is success?</p>
  
  <pre><code>firebase.firestore().collection("expense").add(value);
  </code></pre>