Closed thylo closed 9 years ago
I think you have multiple options to do that.
You can use the promise returned by the dispatcher
$commangular.dispatch('EventA').then(function(){
$commangular.dispatch('EventB')
);
You can even pass the result from the eventA to the EventB as data.
Another option would be to use a @After event aspect
commangular.eventAspect('@After(/.*EventA/)',['$commangular',function($commangular) {
return {
execute: function() {
$commangular.dispatch('EventB');
}
}
});
The aspect will allow you to have the code decoupled from EventA and EventB logic.
If the execution of EventB depends on some conditions you can check it in the aspect logic or you can then use command flows.
Thanks for the answer, I'll look at those more deeply.
Hi,
Just a quick question about nesting events. Let say I have two events running a sequence of commands.
Now i'd like to be able to wait for this "EventA" queue to dispatch the "EventB" queue. I could merge all 6 commands in "EventC" but then I would have to maintain extra code if I want to keep consistency with A or B behaviors.
How would you deal with this ?