Closed jarcane closed 4 years ago
Further investigation by adding a watcher confirms that actually the swap!
call is completed:
loaded https://images.pexels.com/photos/957010/milky-way-starry-sky-night-sky-star-957010.jpeg
"-- Atom Changed --"
"key" :watcher
"atom" #object[cljs.core.Atom {:val {:loaded 1, :error 0, :total 1}}]
"old-state" {:loaded 0, :error 0, :total 1}
"new-state" {:loaded 1, :error 0, :total 1}
However, for some reason when we deref the value, it still shows the old-state. Something is happening out of order here somehow, and I've no idea why.
Continuing investigation: the atom is not the problem. Swaps are happening just fine.
The problem is that instead of returning assets
as it should, the return value of asset-loader
continues to be the return value of requestAnimationFrame
, even when the recursive call should terminate and return the value from the if statement instead. This then causes a crash, because then the demo tries to use that number as an asset map and obviously fails.
Adds a new key function and API for loading assets from URLs with proper loading confirmation before to start the game.
At present, this doesn't work, for two reasons:
swap!
doesn't seem to happen at all.requestAnimationFrame
instead of returning the asset mapPosting this as WIP 'cause I could use some eyes on.