-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
New APIs for getting Promise state and result #5131
Conversation
Js::JavascriptPromise *jsPromise = Js::JavascriptPromise::FromVar(promise); | ||
Js::JavascriptPromise::PromiseStatus status = jsPromise->GetStatus(); | ||
|
||
switch (status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the status be undefined if jsPromise->GetResult() is null here? Just so that we don't return a good status code and then have GetPromiseResult return InvalidArgument- that could be confusing to callers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Promise only has a result once it's resolved or rejected, so GetResult()
will return nullptr even in the Unresolved
case.
lib/Jsrt/ChakraCore.h
Outdated
@@ -58,6 +58,14 @@ typedef enum JsModuleHostInfoKind | |||
JsModuleHostInfo_Url = 0x6 | |||
} JsModuleHostInfoKind; | |||
|
|||
typedef enum JsPromiseStatusCode | |||
{ | |||
JsPromiseStatusCode_Undefined = 0x00, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need some documentation on what the difference between JsPromiseStatusCode_Undefined
and JsPromiseStatusCode_Unresolved
is; can the former ever be returned, or is it just to be used as an initial value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left it in as the default value. I was tempted to leave it out, but I tend to like having an explicit non-value in my enums.
5f0aa71
to
eeeb9f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
…te and result Merge pull request #5131 from kfarnung:promises
Wiki PR: microsoft/ChakraCore-wiki#54