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

    var self = this;

    if (this.isCommandRejected(evt, callback)) {
      return;
    }

    var workWithRevisionGuard = false;
    if (!!this.definitions.event.revision && dotty.exists(evt, this.definitions.event.revision) &&
        !!this.definitions.event.aggregateId && dotty.exists(evt, this.definitions.event.aggregateId)) {
      workWithRevisionGuard = true;
    }

    if (dotty.get(evt, this.definitions.event.name) === this.options.commandRejectedEventName) {
      workWithRevisionGuard = false;
    }

    if (!workWithRevisionGuard) {
      return this.dispatch(evt, callback);
    }

    this.revisionGuard.guard(evt, function (err, done) {
      if (err) {
        debug(err);
        if (callback) {
          try {
            callback([err]);
          } catch (e) {
            debug(e);
            process.emit('uncaughtException', e);
          }
        }
        return;
      }

      self.dispatch(evt, function (errs, extendedEvt, notifications) {
        if (errs) {
          debug(errs);
          if (callback) {
            try {
              callback(errs, extendedEvt, notifications);
            } catch (e) {
              debug(e);
              process.emit('uncaughtException', e);
            }
          }
          return;
        }

        done(function (err) {
          if (err) {
            if (!errs) {
              errs = [err];
            } else if (_.isArray(errs)) {
              errs.unshift(err);
            }
            debug(err);
          }

          if (callback) {
            try {
              callback(errs, extendedEvt, notifications);
            } catch (e) {
              debug(e);
              process.emit('uncaughtException', e);
            }
          }
        });
      });
    });
  }
function (evt, callback) {
    if (!evt || !_.isObject(evt) || !dotty.exists(evt, this.definitions.event.name)) {
      var err = new Error('Please pass a valid event!');
      debug(err);
      if (callback) callback([err]);
      return;
    }

    var self = this;

    if (this.isCommandRejected(evt, callback)) {
      return;
    }

    var workWithRevisionGuard = false;
    if (!!this.definitions.event.revision && dotty.exists(evt, this.definitions.event.revision) &&
        !!this.definitions.event.aggregateId && dotty.exists(evt, this.definitions.event.aggregateId)) {
      workWithRevisionGuard = true;
    }

    if (dotty.get(evt, this.definitions.event.name) === this.options.commandRejectedEventName) {
      workWithRevisionGuard = false;
    }

    if (!workWithRevisionGuard) {
      return this.dispatch(evt, callback);
    }

    this.revisionGuard.guard(evt, function (err, done) {
      if (err) {
        debug(err);
        if (callback) {
          try {
            callback([err]);
          } catch (e) {
            debug(e);
            process.emit('uncaughtException', e);
          }
        }
        return;
      }

      self.dispatch(evt, function (errs, extendedEvt, notifications) {
        if (errs) {
          debug(errs);
          if (callback) {
            try {
              callback(errs, extendedEvt, notifications);
            } catch (e) {
              debug(e);
              process.emit('uncaughtException', e);
            }
          }
          return;
        }

        done(function (err) {
          if (err) {
            if (!errs) {
              errs = [err];
            } else if (_.isArray(errs)) {
              errs.unshift(err);
            }
            debug(err);
          }

          if (callback) {
            try {
              callback(errs, extendedEvt, notifications);
            } catch (e) {
              debug(e);
              process.emit('uncaughtException', e);
            }
          }
        });
      });
    });
  }
function ( evt , callback ) { if ( ! evt || ! _ . isObject ( evt ) || ! dotty . exists ( evt , this . definitions . event . name ) ) { var err = new Error ( 'Please pass a valid event!' ) ; debug ( err ) ; if ( callback ) callback ( [ err ] ) ; return ; } var self = this ; if ( this . isCommandRejected ( evt , callback ) ) { return ; } var workWithRevisionGuard = false ; if ( ! ! this . definitions . event . revision && dotty . exists ( evt , this . definitions . event . revision ) && ! ! this . definitions . event . aggregateId && dotty . exists ( evt , this . definitions . event . aggregateId ) ) { workWithRevisionGuard = true ; } if ( dotty . get ( evt , this . definitions . event . name ) === this . options . commandRejectedEventName ) { workWithRevisionGuard = false ; } if ( ! workWithRevisionGuard ) { return this . dispatch ( evt , callback ) ; } this . revisionGuard . guard ( evt , function ( err , done ) { if ( err ) { debug ( err ) ; if ( callback ) { try { callback ( [ err ] ) ; } catch ( e ) { debug ( e ) ; process . emit ( 'uncaughtException' , e ) ; } } return ; } self . dispatch ( evt , function ( errs , extendedEvt , notifications ) { if ( errs ) { debug ( errs ) ; if ( callback ) { try { callback ( errs , extendedEvt , notifications ) ; } catch ( e ) { debug ( e ) ; process . emit ( 'uncaughtException' , e ) ; } } return ; } done ( function ( err ) { if ( err ) { if ( ! errs ) { errs = [ err ] ; } else if ( _ . isArray ( errs ) ) { errs . unshift ( err ) ; } debug ( err ) ; } if ( callback ) { try { callback ( errs , extendedEvt , notifications ) ; } catch ( e ) { debug ( e ) ; process . emit ( 'uncaughtException' , e ) ; } } } ) ; } ) ; } ) ; }
Call this function to let the denormalizer handle it.
@param {Object}   evt      The event object
@param {Function} callback The function that will be called when this action has finished [optional]
`function(errs, evt, notifications){}` notifications is of type Array
Call this function to let the denormalizer handle it .