title: Can I use $$updated when extending a firebase factory to run a getTotal() function like in the example?
body: <p>Can I receive what is returned by $$updated or have $$updated run a function that I can then receive from every time a task is checked off? </p>
  
  <p>At the end of the day, I need to keep a count of how many tasks users complete. It seems like firebase has ways of automatically syncing that data but it's unclear how to do that specifically. I've run into problems with $watch and running functions when a task is completed. This looks like an interesting way of doing it but I can't put the pieces together. </p>
  
  <p>Here is working plnkr of the code below: <a href="http://plnkr.co/edit/iAGvPHFWn2GSPGzBRpKh?p=preview">http://plnkr.co/edit/iAGvPHFWn2GSPGzBRpKh?p=preview</a></p>
  
  <pre><code>// Code goes here
  angular.module('app', ['firebase']);
  
  angular
    .module('app')
    .controller('main', function($scope, $firebase, $timeout, $window, ListWithTotal) {
  
    var ref = new Firebase("https://plnkr.firebaseio.com");
    $scope.listWithTotal = ListWithTotal(ref);
  
    $scope.addTask = function(task) {  
      $scope.listWithTotal.$add({
        title: task.title,
        complete: false,  
        tally: 0  
      });
      task.title = ''; 
    };
  
    $scope.completeTask = function(task) {  
      if (task.complete === true) {
        task.complete = true;
        task.tally = 1;
      } else { 
        task.complete = false;
        task.tally = 0;
      }
      $scope.listWithTotal.$save(task);
    };
  
    $scope.tallyCount = '';
    //it would be cool if I can get tallyCount to receive 
    //the result of getTotal or automagically with $$updated. 
  
  
  }).factory("ListWithTotal", ["$FirebaseArray", "$firebase", function($FirebaseArray, $firebase) {
    // create a new factory based on $FirebaseArray
    var TotalFactory = $FirebaseArray.$extendFactory({
      getTotal: function() {
        var total = 0;
        angular.forEach(this.$list, function(rec) {
          total += rec.tally;
        });
        return total;
      },
      $$updated: function(){
        return this.$list.getTotal();
      }
    });
    return function(listRef) {
      var sync = $firebase(listRef, {arrayFactory: TotalFactory});
      return sync.$asArray(); // this will be an instance of TotalFactory
    };
  }]);
  </code></pre>