Concurrency: async, await, Promise.all
Links for this example
About this example
This example is a simple simulation of a Slot Machine. The user enters their name in the input field, and it's passed to a Lightbox that opens to start the game. The user is greeted by name and is invited to play. Upon completion of a turn at the slot machine, the Lightbox is closed and the result of the game is returned to the Page.
As in a regular slot machine, three images that randomly “spin” determine the outcome of the game. Each image component has its own loop where the images are randomly alternated, and each new image is shown and hidden with randomly timed animation. A Promise.all waits for all three loops to finish and the result of the game can then be determined - if all three images are the same the user is a winner.