In javascript, how does one await for an event to occur in a function? I want to create a function, waitUntilFullScreenChange(), which returns false when any of the following events occurs:
document.addEventListener("fullscreenchange", function() {
//return false here});
/* Firefox */
document.addEventListener("mozfullscreenchange", function() {
//return false here});
/* Chrome, Safari and Opera */
document.addEventListener("webkitfullscreenchange", function() {
//return false here});
/* IE / Edge */
document.addEventListener("msfullscreenchange", function() {
//return false here });
Is this possible in javascript? I wanted to write a function this way because I need to call a javascript function from a dart file and then parse the result when the event occurs (thus I need to wrap the events in a function and wait for a return value). Thanks for all the help!