Communicating between widget Portal issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:34 AM
I am using $rootscope.$emit() for communicating between widget and for listning $rootscpe.$on().
i am having two widget say A & B.
Step 1. Firstly I am sending data from A to B by using
$rootScope.$emit('saveContinueSkillBehave', '');
Step 2. In B widget I am fetching by using
$rootScope.$on('saveContinueSkillBehave', function(event,showCard) {
// back to A from B
$rootScope.$emit("saveContinueSkillBehaveTotalSkillPer", {
"totalSkillPercentage":"100"
});
});
Step 3. In A widget I am fetching by using
$rootScope.$on('saveContinueSkillBehaveTotalSkillPer', function(e, skillSaveData){
console.log(skillSaveData);
});
so hear in step 3 when i am consoling the output i am getting console as shown in attach image.
As you can see in image
At first flow i am getting 1 time data on console.
At second flow i am getting 2 time data on console(containing first flow output as well)
At forth flow i am getting 4 time data on console(containing first, second, third flow output as well) and so on...
How can i prevent this and i want only final output. please post if anyone have correct solutions.