I am looking to integrate indexdb in a wasm based app. How do you "await" in a go function a promise from a js function. Here is the example
async getItem(key) {
try{
const out = await database.getItem(key);
return out;
}catch(err){
return null;
}
}
and in go
func Get(key string)[]byte{
found := js.Global().Get("Store").Call('getItem', key )
// await for found
// convert js.Value to to []byte
return nil
}
Async callbacks are fine too.
LE: one bad solution would be to create a go routine with an infinite loop waiting until a DOM variable exists like global.solution+ID to be set. But I believe this is a bad solution