You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
Please while having a *Promise exposed out of a js runtime environment into golang one in case of PromiseStatePending what would be the best option to wait/subscribe for event once it is naturally resolved/rejected within the initial runtime? (Except of just a periodical state check)
E.g.
value, err:=vm.RunString(` new Promise(resolve => setTimeout(resolve, 1000)) `)
iferr!=nil {
panic(err)
}
ifp, ok:=value.Export().(*goja.Promise); ok {
switchp.State() {
casegoja.PromiseStateRejected:
panic(p.Result().String())
casegoja.PromiseStateFulfilled:
result=p.Result().Export()
default:
// how to get notified once it is resolved/rejected
}
}
For the very same reason please clarify from the docs of NewPromise
The returned values are not goroutine-safe and must not be called in parallel with VM running. In order to make use of this method you need an event loop
Do I see it right that runtime.RunString and all the similar handles its own event loop under the hood. And once runtime.RunString execution is ended (returned a value) whether underling event loop still keep on further processing?
Thnx
The text was updated successfully, but these errors were encountered:
Hi.
Please while having a
*Promise
exposed out of ajs
runtime environment into golang one in case ofPromiseStatePending
what would be the best option to wait/subscribe for event once it is naturally resolved/rejected within the initial runtime? (Except of just a periodical state check)E.g.
For the very same reason please clarify from the docs of
NewPromise
Do I see it right that
runtime.RunString
and all the similar handles its own event loop under the hood. And onceruntime.RunString
execution is ended (returned a value) whether underling event loop still keep on further processing?Thnx
The text was updated successfully, but these errors were encountered: