I need some assistance. I have been working on tracking user clicks. The issue is that I have a list where users can click to fetch data from the server. However, when multiple users click simultaneously, it results in multiple requests being sent to the server.
What I am aiming for is to ensure only one request is made to the server upon each click.
So far, this is what I have implemented:
function retrieveData(id) {
_this.previousClickId = _this.currentId;
dataFactory.retrieveListOfData(id).then(function(response) {
if(_.isEqual(_this.previousClickId, id)){
displayData(response);
} else {
retrieveData(executionId);
}
});
_this.currentId = id;
}
Below is the HTML code:
<ul>
<li ng-click="retrieveData(1)">option1</li>
<li ng-click="retrieveData(2)">option2</li>
</ul>