Despite finding numerous resources, I am still struggling to fully grasp the concept at hand. The issue revolves around two functions in particular:
roulette_animation(){
do animation (may take 5 sec)
}
alertResult(){
alert('You win')
}
My objective is to ensure that the alertResult()
function only executes after the roulette_animation()
function has completed its task.
The roulette_animation
function is facilitated by a JavaScript library that lacks a specific state
indicating whether the animation has concluded or not.
In my case, the outcome is already predetermined before the animation commences, ultimately leading to the desired result. However, the alert prompt currently interrupts this sequence. My current solution involves adding a time delay between the two functions, but this method is flawed as different browsers may load the animation at varying speeds.
While I realize providing additional snippets of code would be beneficial, the sheer volume of information makes it impractical. If modifying the existing JavaScript code is necessary, I am willing to do so. Nonetheless, I am curious if there exists a workaround for this asynchronous dilemma?