src/appstate.js
function runSyncBranch (index, currentBranch, options) {
  var { args, tree, signal, state, start, promise, services } = options;

  try {
    var action = currentBranch;
    var actionFunc = tree.actions[action.actionIndex];
    var actionArgs = createActionArgs(args, action, state, false);
    var outputs = action.outputs ? Object.keys(action.outputs) : [];

    action.mutations = [];
    action.args = merge({}, args);

    var next = createNextSyncAction(actionFunc, outputs);
    actionFunc.apply(null, actionArgs.concat(next, services));

    var result = next._result || {};
    merge(args, result.args);

    action.isExecuting = false;
    action.hasExecuted = true;
    action.output = result.args;

    if (result.path) {
      action.outputPath = result.path;
      var output = action.outputs[result.path];

      var runResult = runBranch(0, {
        args, signal, state, start, promise, services,
        tree: {
          actions: tree.actions,
          branches: output
        }
      });

      if (runResult && runResult.then) {
        return runResult.then(() => {
          return runBranch(index + 1, options);
        });
      }

      return runBranch(index + 1, options);
    }
    return runBranch(index + 1, options);
  } catch (e) {
    promise.reject(e);
  }
}
function runSyncBranch (index, currentBranch, options) {
  var { args, tree, signal, state, start, promise, services } = options;

  try {
    var action = currentBranch;
    var actionFunc = tree.actions[action.actionIndex];
    var actionArgs = createActionArgs(args, action, state, false);
    var outputs = action.outputs ? Object.keys(action.outputs) : [];

    action.mutations = [];
    action.args = merge({}, args);

    var next = createNextSyncAction(actionFunc, outputs);
    actionFunc.apply(null, actionArgs.concat(next, services));

    var result = next._result || {};
    merge(args, result.args);

    action.isExecuting = false;
    action.hasExecuted = true;
    action.output = result.args;

    if (result.path) {
      action.outputPath = result.path;
      var output = action.outputs[result.path];

      var runResult = runBranch(0, {
        args, signal, state, start, promise, services,
        tree: {
          actions: tree.actions,
          branches: output
        }
      });

      if (runResult && runResult.then) {
        return runResult.then(() => {
          return runBranch(index + 1, options);
        });
      }

      return runBranch(index + 1, options);
    }
    return runBranch(index + 1, options);
  } catch (e) {
    promise.reject(e);
  }
}
function runSyncBranch ( index , currentBranch , options ) { var { args , tree , signal , state , start , promise , services } = options ; try { var action = currentBranch ; var actionFunc = tree . actions [ action . actionIndex ] ; var actionArgs = createActionArgs ( args , action , state , false ) ; var outputs = action . outputs ? Object . keys ( action . outputs ) : [ ] ; action . mutations = [ ] ; action . args = merge ( { } , args ) ; var next = createNextSyncAction ( actionFunc , outputs ) ; actionFunc . apply ( null , actionArgs . concat ( next , services ) ) ; var result = next . _result || { } ; merge ( args , result . args ) ; action . isExecuting = false ; action . hasExecuted = true ; action . output = result . args ; if ( result . path ) { action . outputPath = result . path ; var output = action . outputs [ result . path ] ; var runResult = runBranch ( 0 , { args , signal , state , start , promise , services , tree : { actions : tree . actions , branches : output } } ) ; if ( runResult && runResult . then ) { return runResult . then ( ( ) => { return runBranch ( index + 1 , options ) ; } ) ; } return runBranch ( index + 1 , options ) ; } return runBranch ( index + 1 , options ) ; } catch ( e ) { promise . reject ( e ) ; } }
Run sync branch
@param {Number} index
@param {Object} currentBranch
@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
@returns {Promise|undefined}
Run sync branch