In my app i have multiple listeners (watchers) on different events of same contract. Nothing complicated.
let songAddedEvent = instance.SongAdded({}, {
fromBlock: 'latest',
toBlock: 'latest'
});
songAddedEvent.watch(function (error, result) {
if (error) {
console.error(error);
}
console.log(result);
}
-------------
/////////////////////////////////////////
-------------------------
let newVoteEvent = instance.NewVote({}, {
fromBlock: 'latest',
toBlock: 'latest'
});
newVoteEvent.watch(function (error, result) {
if (error) {
console.error(error);
}
console.log(result);
}
Problem is that same event is caught multiple times, and strange thing is that event is caught exactly number_of_listeners times.
So in this case i have two listener on two different events and triggered listener is triggered 2 times
Tried with 3 listeners, then is triggered 3 times.
(Not all of them are triggered, just one listener multiple times).
I read this article https://github.com/ethereum/web3.js/issues/398 but doesn't explain why there is correlation between number of listeners and multiplication of event triggers.
Forgot to mention, console.log is called from same .js file and same line in that file.
Does somebody have an idea why is this happening??