lib/domain.js
function (cmd, callback) {
    if (!cmd || !_.isObject(cmd) || !dotty.exists(cmd, this.definitions.command.name)) {
      var err = new Error('Please pass a valid command!');
      debug(err);
      if (callback) callback(err);
      return;
    }

    var self = this;
    process.nextTick(function () {
      if (callback && callback.length > 2) {
        self.commandDispatcher.dispatch(cmd, function (err, eventsToDispatch, aggregateData, meta) {
          self.onDispatched(cmd, err, eventsToDispatch, aggregateData, meta, callback);
        });
        return;
      }
      self.commandDispatcher.dispatch(cmd, function (err, eventsToDispatch) {
        self.onDispatched(cmd, err, eventsToDispatch, null, null, callback);
      });
    });
  }
function (cmd, callback) {
    if (!cmd || !_.isObject(cmd) || !dotty.exists(cmd, this.definitions.command.name)) {
      var err = new Error('Please pass a valid command!');
      debug(err);
      if (callback) callback(err);
      return;
    }

    var self = this;
    process.nextTick(function () {
      if (callback && callback.length > 2) {
        self.commandDispatcher.dispatch(cmd, function (err, eventsToDispatch, aggregateData, meta) {
          self.onDispatched(cmd, err, eventsToDispatch, aggregateData, meta, callback);
        });
        return;
      }
      self.commandDispatcher.dispatch(cmd, function (err, eventsToDispatch) {
        self.onDispatched(cmd, err, eventsToDispatch, null, null, callback);
      });
    });
  }
function ( cmd , callback ) { if ( ! cmd || ! _ . isObject ( cmd ) || ! dotty . exists ( cmd , this . definitions . command . name ) ) { var err = new Error ( 'Please pass a valid command!' ) ; debug ( err ) ; if ( callback ) callback ( err ) ; return ; } var self = this ; process . nextTick ( function ( ) { if ( callback && callback . length > 2 ) { self . commandDispatcher . dispatch ( cmd , function ( err , eventsToDispatch , aggregateData , meta ) { self . onDispatched ( cmd , err , eventsToDispatch , aggregateData , meta , callback ) ; } ) ; return ; } self . commandDispatcher . dispatch ( cmd , function ( err , eventsToDispatch ) { self . onDispatched ( cmd , err , eventsToDispatch , null , null , callback ) ; } ) ; } ) ; }
Call this function to let the domain handle it.
@param {Object}   cmd      the command object
@param {Function} callback the function that will be called when this action has finished [optional]
`function(err, evts, aggregateData, meta){}` evts is of type Array, aggregateData and meta are an object
Call this function to let the domain handle it .