我正在为WebAssembly编写此程序,我需要等待js promise被解决。该怎么做?
所有代码(还有第二个错误,我不知道如何处理):
package main
import (
"syscall/js"
"time"
)
func setIntervalAsync(function js.Value, timeout js.Value, getState js.Value){
_timeout := timeout.Int()
Start:
time.Sleep(time.Duration(_timeout) * time.Millisecond)
function.Invoke().Await()
// function.Invoke().Await undefined (type js.Value has no field or method Await)
canceled := getState.Invoke().Bool()
if(!canceled){ goto Start }
}
func main() {
setFunction := js.Global().Get("&#!go_intermediate_D6&W#R&@87ycm")
callback := js.NewCallback(setIntervalAsync)
// undefined: js.NewCallback
defer callback.Release()
setFunction.Invoke()
}