(I don't think this is a duplicate of How do I make asynchronous calls in an event handler , even though the title is similar. It is also different from questions about disabling buttons, since there may be lots of different events that can cause asynchronous conflicts.)
When, while visiting my webpage, a button is clicked or a key is pressed, I want to be able to do asynchronous Promise chains, such as to read a database, to read a file, or to write a log entry. But these require leaving the event handler/listener, so it seems impossible to return a value from the original handler at the end of the 'then' chain.
This is okay, but the problem with returning from a handler synchronously (that is, immediately) is that the user might click the same button or press the key again, or even do an unrelated action, which might trigger a conflicting asynchronous operation (assuming that these operations cannot be done in parallel).
I guess I want to 'deaden' the event system while the asynchronous operations are in progress (with a timeout in case of unexpected failure to terminate, perhaps), but this feels dangerous. It surely can't be the right thing to do.