Skip to content

Instantly share code, notes, and snippets.

@buildmaster
Last active August 29, 2015 14:22
Show Gist options
  • Save buildmaster/da583c759032be971831 to your computer and use it in GitHub Desktop.
Save buildmaster/da583c759032be971831 to your computer and use it in GitHub Desktop.
//as you raise the events to run you should save the number of events in process
Hoist.data('EventMeta').save({_id:correlationid+'_my_event_count', count:numberOfEventsFired})
//after each event is processed
Hoist.lock('module_count'+correlationid).then(function(){
Hoist.data('EventMeta').findById(correlationid+'_my_event_count').then(function(eventMeta){
eventMeta.numberOfEvents --;
return Hoist.data('EventMeta').save(eventMeta);
});
}).then(function(eventMeta){
if(eventMeta.numberOfEvents<1){
//raise done event;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment