I am currently facing challenges with event handling in AngularJs. In my service, I send out events using the following line of code :
$rootScope.$emit("FNH."+this.status, flowNodeHelper);
When receiving the event in service "S1," I handle it as follows :
$rootScope.$on('FNH.READY', function(event, flowNodeHelper) {
flowNodeHelperService.setActive(flowNodeHelper);
});
$rootScope.$on('FNH.ACTIVE', function(event, flowNodeHelper) {
flowNodeHelperService.setCompleting(flowNodeHelper);
});
$rootScope.$on('FNH.COMPLETING', function(event, flowNodeHelper) {
flowNodeHelperService.setCompleted(flowNodeHelper);
});
$rootScope.$on('FNH.COMPLETED', function(event, flowNodeHelper) {
flowNodeHelperService.setClose(flowNodeHelper);
});
Similarly, in a directive, I handle the events in the same way:
$rootScope.$on('FNH.READY', function(event, flowNodeHelper) {
console.log(flowNodeHelper + " status is ready");
});
$rootScope.$on('FNH.ACTIVE', function(event, flowNodeHelper) {
console.log(flowNodeHelper + " status is active");
});
$rootScope.$on('FNH.COMPLETING', function(event, flowNodeHelper) {
console.log(flowNodeHelper + " status is completing");
});
...
However, I noticed that the order of event reception differs between my service "S1" and the directive. How can I ensure consistency in event order between the two?