-
-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] How to get the Promise result value? #69
Comments
I think this will be possible after merging #68. |
Hey @kuoruan; |
I'd like this too, but for simplicity, I don't need complex/useful value types. The following code would be totally fine:
I think I can effectively get there with FunctionTemplates and some ugly code, but also happy to contribute. |
Hey @fizx I'm working on the Object/Promise code right now. val.AsPromise().Result() |
Hi @rogchap , I see you added the support for Object, do you have a plan to add Promise? I'm trying to get Promise result from a promise result with your code: RtnValue PromiseResult(ValuePtr ptr) {
LOCAL_OBJECT(ptr);
RtnValue rtn = {nullptr, nullptr};
Local<Promise> promise = obj.As<Promise>();
std::cout << promise->State() << std::endl;
while (promise->State() == Promise::kPending) {
iso->RunMicrotasks();
}
if (promise->State() != Promise::kFulfilled) {
rtn.error = ExceptionError(try_catch, iso, local_ctx);
} else {
MaybeLocal<Value> result = promise->Result();
m_value* new_val = new m_value;
new_val->iso = iso;
new_val->ctx.Reset(iso, local_ctx);
new_val->ptr.Reset(iso, Persistent<Value>(iso, result.ToLocalChecked()));
rtn.value = static_cast<ValuePtr>(new_val);
}
return rtn;
} If I run code like But code like Any thing I'm wrong? |
Hey @kuoruan Yes, I am working on full support for Promise API as I can imagine people wanting to be able to do thinks like the You seem to be on the right track to get the Promise Result, I know that |
@kuoruan I've noticed another error: |
Hi @rogchap I tried this:
create a new file like:
no error found. |
OK, there is only |
d8 is different from v8; d8 implements setTimeout for debugging v8. d8 is an example of a CLI tool that uses v8, just like any program that uses v8go would also. |
I want to get the Promise result, for the example code is
1
The text was updated successfully, but these errors were encountered: