src/modules/guiEngine/recloop.js
function rec() {
      // Start a new promise.
      return Promise.fromNode(function(cb) {
        // Apply jitter to interval to get next timeout duration.
        var duration = applyJitter(opts.jitter, opts.interval);
        // Init a timeout.
        setTimeout(function() {
          // Run handler function.
          return $q.try(fn)
          // Handle errors.
          .catch(function(err) {
            return errorHandler(err);
          })
          // Resolve promise.
          .nodeify(cb);
        }, duration);
      })
      // Recurse unless top flag has been set.
      .then(function() {
        if (!stopFlag) {
          return rec();
        }
      });
    }
function rec() {
      // Start a new promise.
      return Promise.fromNode(function(cb) {
        // Apply jitter to interval to get next timeout duration.
        var duration = applyJitter(opts.jitter, opts.interval);
        // Init a timeout.
        setTimeout(function() {
          // Run handler function.
          return $q.try(fn)
          // Handle errors.
          .catch(function(err) {
            return errorHandler(err);
          })
          // Resolve promise.
          .nodeify(cb);
        }, duration);
      })
      // Recurse unless top flag has been set.
      .then(function() {
        if (!stopFlag) {
          return rec();
        }
      });
    }
function rec ( ) { // Start a new promise. return Promise . fromNode ( function ( cb ) { // Apply jitter to interval to get next timeout duration. var duration = applyJitter ( opts . jitter , opts . interval ) ; // Init a timeout. setTimeout ( function ( ) { // Run handler function. return $q . try ( fn ) // Handle errors. . catch ( function ( err ) { return errorHandler ( err ) ; } ) // Resolve promise. . nodeify ( cb ) ; } , duration ) ; } ) // Recurse unless top flag has been set. . then ( function ( ) { if ( ! stopFlag ) { return rec ( ) ; } } ) ; }
Recursive function.
Recursive function .