Skip to content
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

Merged
merged 1 commit into from
May 11, 2018

Conversation

kfarnung
Copy link
Contributor

@kfarnung kfarnung commented May 10, 2018

@kfarnung kfarnung self-assigned this May 10, 2018
Js::JavascriptPromise *jsPromise = Js::JavascriptPromise::FromVar(promise);
Js::JavascriptPromise::PromiseStatus status = jsPromise->GetStatus();

switch (status)
Copy link
Contributor

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

Copy link
Contributor Author

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.

@@ -58,6 +58,14 @@ typedef enum JsModuleHostInfoKind
JsModuleHostInfo_Url = 0x6
} JsModuleHostInfoKind;

typedef enum JsPromiseStatusCode
{
JsPromiseStatusCode_Undefined = 0x00,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@boingoing boingoing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@chakrabot chakrabot merged commit 4b015fa into chakra-core:release/1.9 May 11, 2018
chakrabot pushed a commit that referenced this pull request May 11, 2018
@kfarnung kfarnung deleted the promises branch May 11, 2018 01:44
chakrabot pushed a commit that referenced this pull request May 11, 2018
…te and result

Merge pull request #5131 from kfarnung:promises
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants