code: function(callback, digest, scope) {
        // grab function reference for storing state details
        var nextTick = $mdUtil.nextTick;
        var timeout = nextTick.timeout;
        var queue = nextTick.queue || [];
  
        // add callback to the queue
        queue.push({scope: scope, callback: callback});
  
        // set default value for digest
        if (digest == null) digest = true;
  
        // store updated digest/queue values
        nextTick.digest = nextTick.digest || digest;
        nextTick.queue = queue;
  
        // either return existing timeout or create a new one
        return timeout || (nextTick.timeout = $timeout(processQueue, 0, false));
  
        /**
         * Grab a copy of the current queue
         * Clear the queue for future use
         * Process the existing queue
         * Trigger digest if necessary
         */
        function processQueue() {
          var queue = nextTick.queue;
          var digest = nextTick.digest;
  
          nextTick.queue = [];
          nextTick.timeout = null;
          nextTick.digest = false;
  
          queue.forEach(function(queueItem) {
            var skip = queueItem.scope && queueItem.scope.$$destroyed;
            if (!skip) {
              queueItem.callback();
            }
          });
  
          if (digest) $rootScope.$digest();
        }
      }
docs: Alternative to $timeout calls with 0 delay.
  nextTick() coalesces all calls within a single frame
  to minimize $digest thrashing
  
  @param {Function} callback function to be called after the tick
  @param {boolean} digest true to call $rootScope.$digest() after callback
  @param scope scope associated with callback. If the scope is destroyed, the callback will
  be skipped.
  @returns {*}