Hello! I have issue with waiting for result from async procedure with await.
Source code: ~akagi/sei-no - sourcehut git
All that I want is to create most important effect in playwriting: fade out, changing background image after it, and fade in.
Please try to run code from source hut – at this moment I dont understand how to pass function for delay (1 second) evaluation after animation with setTimeout.
Start game with make serve
.
Missing resources is here:
Hi @liltechdude! While I don’t have the time to try running your program, I can offer a bit of advice. First, making it easy to write asynchronous programs with Hoot is something we’re still working on, so a good “out of the box” solution will arrive in a future release. In the meantime, what I recommend doing is writing your own wrapper around JS promises. async/await in JS is just syntactic sugar around promises, so you might want a way to call the then
method from Scheme so you can register callbacks when the promises resolve/break.
I see that you have a sleep
procedure whose JS implementation uses setTimeout
in game.js
. One immediate issue I see is that you are calling func
when you should just be passing a reference: You have setTimeout(func(), duration_ms)
but it should be more like setTimeout(func, duration_ms)
.
Hope this helps!
Oh my! This problem is solved!!
I will write guide in future how my application works.
This is fix: ~akagi/sei-no: [MVP] Fading is working - sourcehut git
2 Likes