lib/eventDispatcher.js
function trigger (dispatcher) {
  var queue = dispatcher.undispatchedEventsQueue || []
  var event;

  // if the last loop is still in progress leave this loop
  if (dispatcher.isRunning) return;

  dispatcher.isRunning = true;

  (function next (e) {

    // dipatch one event in queue and call the _next_ callback, which
    // will call _process_ for the next undispatched event in queue.
    function process (event, nxt) {

      // Publish it now...
      debug('publish event...');
      dispatcher.publisher(event.payload, function(err) {
        if (err) {
          return debug(err);
        }
        // ...and set the published event to dispatched.
        debug('set event to dispatched...');
        dispatcher.store.setEventToDispatched(event, function(err) {
          if (err) {
            debug(err);
          } else {
            debug('event set to dispatched');
          }
        });
      });

      nxt();
    }

    // serial process all events in queue
    if (!e && queue.length) {
      process(queue.shift(), next)
    } else {
      debug(e);
    }
  })();

  dispatcher.isRunning = false;
}
function trigger (dispatcher) {
  var queue = dispatcher.undispatchedEventsQueue || []
  var event;

  // if the last loop is still in progress leave this loop
  if (dispatcher.isRunning) return;

  dispatcher.isRunning = true;

  (function next (e) {

    // dipatch one event in queue and call the _next_ callback, which
    // will call _process_ for the next undispatched event in queue.
    function process (event, nxt) {

      // Publish it now...
      debug('publish event...');
      dispatcher.publisher(event.payload, function(err) {
        if (err) {
          return debug(err);
        }
        // ...and set the published event to dispatched.
        debug('set event to dispatched...');
        dispatcher.store.setEventToDispatched(event, function(err) {
          if (err) {
            debug(err);
          } else {
            debug('event set to dispatched');
          }
        });
      });

      nxt();
    }

    // serial process all events in queue
    if (!e && queue.length) {
      process(queue.shift(), next)
    } else {
      debug(e);
    }
  })();

  dispatcher.isRunning = false;
}
function trigger ( dispatcher ) { var queue = dispatcher . undispatchedEventsQueue || [ ] var event ; // if the last loop is still in progress leave this loop if ( dispatcher . isRunning ) return ; dispatcher . isRunning = true ; ( function next ( e ) { // dipatch one event in queue and call the _next_ callback, which // will call _process_ for the next undispatched event in queue. function process ( event , nxt ) { // Publish it now... debug ( 'publish event...' ) ; dispatcher . publisher ( event . payload , function ( err ) { if ( err ) { return debug ( err ) ; } // ...and set the published event to dispatched. debug ( 'set event to dispatched...' ) ; dispatcher . store . setEventToDispatched ( event , function ( err ) { if ( err ) { debug ( err ) ; } else { debug ( 'event set to dispatched' ) ; } } ) ; } ) ; nxt ( ) ; } // serial process all events in queue if ( ! e && queue . length ) { process ( queue . shift ( ) , next ) } else { debug ( e ) ; } } ) ( ) ; dispatcher . isRunning = false ; }
Triggers to publish all events in undispatchedEventsQueue.
Triggers to publish all events in undispatchedEventsQueue .