Reputation: 25
I have issue that I need to get updated some var if someone confirm something example: I have if statement that checks for some command (!run). If this command is run, then the user has to confirm something and I need to check if it is confirmed, then do something after that confirmation verification... It wont do something after user accept or decline...
let verification = "";
manager.on('checkVerification' function(err) =>{
if(confirmation.state == "accepted"){
verifivation = "true";
} else if (confirmation.state == "declined"){
verification = "false"
console.log('user declined confirmation')
}
})
if (command = !run ......){
send.confirmation
if (verification === "true"){
//do something
}else if(verification === "false"){
//do something
}
Upvotes: 1
Views: 56
Reputation: 45
You can set interval, then end it.
if (command = !run ......){
send.confirmation
var myVar = setInterval(myTimer, 3000); function myTimer() {
if (verification === "true"){
clearInterval(myVar);
//do something
}else if(verification === "false"){
clearInterval(myVar);
//do something
}
}
Upvotes: 1