src/appstate.js
function runBranch (index, options) {
  var { tree, signal, start, promise } = options;
  var currentBranch = tree.branches[index];

  if (!currentBranch && tree.branches === signal.branches) {
    if (tree.branches[index - 1]) {
      tree.branches[index - 1].duration = Date.now() - start;
    }

    signal.isExecuting = false;

    if (promise) {
      promise.resolve(signal);
    }

    return;
  }

  if (!currentBranch) {
    return;
  }

  if (Array.isArray(currentBranch)) {
    return runAsyncBranch(index, currentBranch, options);
  } else {
    return runSyncBranch(index, currentBranch, options);
  }
}
function runBranch (index, options) {
  var { tree, signal, start, promise } = options;
  var currentBranch = tree.branches[index];

  if (!currentBranch && tree.branches === signal.branches) {
    if (tree.branches[index - 1]) {
      tree.branches[index - 1].duration = Date.now() - start;
    }

    signal.isExecuting = false;

    if (promise) {
      promise.resolve(signal);
    }

    return;
  }

  if (!currentBranch) {
    return;
  }

  if (Array.isArray(currentBranch)) {
    return runAsyncBranch(index, currentBranch, options);
  } else {
    return runSyncBranch(index, currentBranch, options);
  }
}
function runBranch ( index , options ) { var { tree , signal , start , promise } = options ; var currentBranch = tree . branches [ index ] ; if ( ! currentBranch && tree . branches === signal . branches ) { if ( tree . branches [ index - 1 ] ) { tree . branches [ index - 1 ] . duration = Date . now ( ) - start ; } signal . isExecuting = false ; if ( promise ) { promise . resolve ( signal ) ; } return ; } if ( ! currentBranch ) { return ; } if ( Array . isArray ( currentBranch ) ) { return runAsyncBranch ( index , currentBranch , options ) ; } else { return runSyncBranch ( index , currentBranch , options ) ; } }
Run tree branch, or resolve signal
if no more branches in recursion.
@param {Number} index
@param {Object} options
@param {Object} options.tree
@param {Object} options.args
@param {Object} options.signal
@param {Object} options.promise
@param {Date}   options.start
@param {Baobab} options.state
@param {Object} options.services
Run tree branch or resolve signal if no more branches in recursion .