Is there a better way of unregistering an event li...
# javascript
r
Is there a better way of unregistering an event listener in its body than the following approach?
Copy code
lateinit var fSelf: (Event) -> Unit
val f = { _: Event ->
    document.querySelectorAll(".contextMenu").asList().forEach {
        (it as HTMLElement).style.visibility = "hidden"
    }
    window.removeEventListener("click", fSelf)
}
fSelf = f
window.addEventListener("click", f)