In Javascript, how to control data contention if the event listener is asynchronous?

consider the following code

whatever.onclick = async () => {
    const a = await(await fetch("step-1")).text();
    const b = await(await fetch("step-2")).text();
    whatever.textContent = a + b;
}
The

event listener is asynchronous, so if the user clicks again between step-1 and step-2 , there will be competition. Remote is a third party, so it can"t be controlled.

now there are several possible requirements:

  • discard the new request if the previous request has not been completed; or
  • if the previous request has not been completed, the new request should be returned with the old request; or
  • if the previous request has not been completed, the new request should be queued.

do you have a suitable wheel, or do you have to build it yourself?

feels that this is a very reasonable requirement. Why doesn"t loadsh have

?
Mar.19,2021

set a time limit for async. Click, that is triggered repeatedly in a short period of time is actually executed only once.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ebd3e6-473ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ebd3e6-473ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?