New to Vue.js and currently exploring the following challenge:
I have a component named PopUp
which can be displayed or hidden using functions of the same name.
My goal is for the popUp.show()
function to return a promise that contains information about how the user closed the popUp (such as button press, clicking outside the popup, etc).
The main issue I'm encountering is figuring out how to efficiently wait for the closure information. Initially, I considered using a loop, but this approach seems inefficient and could potentially stall the entire program.
One idea I had was to implement something like this:
async show() {
//Insert Show PopUp code
return this.resolve()
}
hide() {
//Insert hide code
this.closed = true;
}
resolve() {
while(!this.closed){}
//insert build response object code
return response
}
I'm wondering if there's a better way to listen for changes in a variable rather than employing a looping mechanism.
Appreciate any insights!