Hey, just starting out with liveview and want to make sort of a game with it. The problem I’m having is with adding animations. To quickly explain how the game works: you have two dices, one is rolled at the start of a game, let’s say to a value of 3, the other dice however is hidden and will roll at the end of a game. Users can place their guesses if the second dice value will be higher/lower or equal. Users have 10 seconds to place their guesses and at the end of that time the second dice reveals it’s value.
The issue that i’m having is that at the end of the timer we basically switch out the current round for a new one on the server and new guesses start pouring. What’s the proper way for me to halt new updates from liveview until an animation that reveals the second dice is finished?
If you trigger the animation via a JS command, it should block any events until it finishes, in my experience. You could fill that with a dummy animation/time to cover your real animation if you cant trigger it via a JS command for whatever reason.
Probably the simplest way without having your own timers and stuff.
Actions are chained and updates are executed using a queue.
flags are used to disable few elements based on it - example isAnimating flag will prevent new animations from triggering until current animation is complete.
You can try out these techniques in LiveView to solve your problem.
Only client side fixes won’t solve this issue completely - something on the server side will have to coordinate these.