title: Tracking Replication / Changes in pouchdb
body: <p>I'm trying to track the changes when pouchdb replicates in order to create a loading screen.</p>
  
  <p>I have several databases with a 2000 or so documents in each and initial load takes quite a while so I want the app to give an indication to the user what is happening in the background.</p>
  
  <pre><code>  //define vars
    var nameDB = "location";
    var remoteDB = new PouchDB("http://localhost:5984/" + nameDB);
    var localDB = new PouchDB(nameDB);
    var localdocCount;
    var localdocCounter = 0;
    var remotedocCount;
  
    //wrap replication in reusable function
    function replicate(){
      //replicate TO the server
      PouchDB.replicate(localDB,remoteDB, {
        continuous: false,
        attachments: true
      },
      function(){
  
          //on callback replicate FROM server
          PouchDB.replicate(remoteDB,localDB, {
            continuous: false,
            attachments: true
          },
          function(){
             //replicate FROM complete
          );
      });
  
      //compact local database to keep size down
      //all revisions are replicated to the server 
      //no need to keep them locally
      localDB.compact();
    }
  
    //get the remote db info first and see how many documents it has
    //remote update_seq how does it match up to localdb update_seq?
    remoteDB.info(function(err, info) {
      remotedocCount = info.doc_count;
      console.log(info);
    });
  
    //get info for local db for comparison with remote
    localDB.info(function(err, info) {
  
      localdocCount = info.doc_count;
  
      //Actually run the replication now that we have the 
      //remote and local db info
      replicate();
  
      //track any changes to the localdb
      localDB.changes({
        continuous: true,
        onChange: function(){
  
          //change detected increment counter
          localdocCounter++;
  
          console.log("Downloaded " 
            + (localdocCount + localdocCounter) 
            + " of " + remotedocCount + " to " + nameDB);
  
          //localdocCount === The total Documents in the local database
          //localdocCounter === The changes that have been made since
          //remotedocCount === The amount of documents we need
  
  
        }
  
      });
    });
  </code></pre>
  
  <p>The code above is my attempt at tracking the amount of documents being downloaded from the server to the client.</p>
  
  <p>The code above works I can see that the documents are downloading.</p>
  
  <p>However this only takes care of a first load scenario what about when a user updates a document?</p>
  
  <p>This is where I think update_seq comes in play.</p>
  
  <p>But I cant figure out how to use update_seq to get an accurate idea of the changes that need to take place.</p>
  
  <p>So to summarise I can see if changes are taking place, but I cant see how to get a total amount of changes needed for the application to consider itself up to date.</p>
  
  <p>Maybe this approach is completely off?</p>