This web3js event listener is part of a Voting Dapp. The listener listens for a transactions and re-renders the page to show updates.
listenForEvents: function() {
App.contracts.Election.deployed().then(function(instance) {
instance.votedEvent({}, {
fromBlock: 0,
toBlock: 'latest'
}).watch(function(error, event) {
console.log("event triggered", event)
// Reload when a new vote is recorded
App.render();
});
});
},
Even after a lot of searches,i cannot find an explanation for the part
{
fromBlock: 0,
toBlock: 'latest'
}
I think this part is causing to render the app in loop. Event declaration is like
event votedEvent (uint indexed _candidateId);
The statement that calls the event is
votedEvent(_candidateId);
Any links or topics to search for will be helpfull.Thanks in advance :-)