Skip to content

Commit

Permalink
lib/hermes-bus.js: Now waits until afterHooks are resolved and then r…
Browse files Browse the repository at this point in the history
…esolves the '.then' function of the trigger
  • Loading branch information
jahnestacado committed Apr 17, 2016
1 parent d618bc1 commit ca70f19
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/hermes-bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ HermesBus.prototype.subscribe = function subscribe() {
};

HermesBus.prototype.unsubscribe = function unsubscribe() {
var self = this;
var subscribedObjectInfo = _utilityBelt.getSubscribedObjectInfo(arguments);
var buslineName = subscribedObjectInfo.buslineName;
var subscribedObject = subscribedObjectInfo.subscribedObject;
Expand Down Expand Up @@ -185,12 +184,10 @@ var _utilityBelt = {
if(eventHandlers[busline][eventName].isActive){
//on-event callback arguments to array
var args = Array.prototype.slice.call(arguments);
executeBeforeHooks(args).then(function(){
executeEvent(args).then(function(){
defer.resolve();
executeAfterHooks(args);
});
});
executeBeforeHooks(args)
.then(function(){return executeEvent(args)})
.then(function(){return executeAfterHooks(args)})
.then(function(){defer.resolve()});
} else{
defer.resolve();
}
Expand Down

0 comments on commit ca70f19

Please sign in to comment.