For example, what if we could do
document.querySelector('a#some-link').addEventListener(async function() {
let result = await someThingThatWeNeed()
// ... possibly show a loading icon, or something ...
// Finally, abort default behavior depending on the result.
if (!result) return false
// otherwise the action continues as normal.
})
It might be possible to monkey-patch addEventListener
to make a POC of this, as well as any other native places where behavior can depend on the result of a function passed to native code.
What are your thoughts and feedback on this idea?