I'm writing a minesweeper clone using Seesaw. For the minefield, I'm using a simple grid-panel
of buttons. I've gotten to the point where when you click on a button, it will flood fill the grid to uncover all the empty tiles surrounding where you clicked. To "uncover the tile", I'm just disabling the button associated with the tile.
The problem is, it's uncovering incrementally, even though the task being executed isn't that expensive. It will update a few spotty buttons around the grid randomly over time, and it looks really bad. I would rather have a second of lag than for it to disable the buttons procedurally.
This is basically the button click handler:
(doseq [b buttons] ; Buttons are the grid cells
(let [[tx ty] (sc/user-data b) ; The cell position is stored in the user data
tile (b/get-tile-at board tx ty)] ; O(1) lookup
(when (:uncovered? tile)
(sc/invoke-later ; Because this chunk is actually being executed in a pool
(sc/config! b :enabled? false)))))
Since there's nothing expensive going on here, it seems like each config!
call makes a change to a button, and the button's appearances are updated as the changes happen.
Is there a way to have every call to config!
/button update happen all at once, even if it creates a small amount of perceived lag?