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 Promise and Reference docs #243

Closed
wants to merge 1 commit into from
Closed

New Promise and Reference docs #243

wants to merge 1 commit into from

Conversation

jschlight
Copy link
Contributor

Continuing work for nodejs/abi-stable-node#280

```

* `[in] value`: The value which is to be referenced.
Copy link
Member

Choose a reason for hiding this comment

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

I think we should say

The Value object which is to be referenced.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM, @gabrielschulhof could you also take a read through.

@mhdawson
Copy link
Member

mhdawson commented May 1, 2018

@gabrielschulhof ping

@@ -1,5 +1,70 @@
# Promise

You are reading a draft of the next documentation and it's in continuos update so
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: common typo: 'continuos' -> 'continuous'


```cpp
Promise::Deferred(napi_env env);
Copy link
Contributor

Choose a reason for hiding this comment

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

@gabrielschulhof Do you remember why we expose both a factory and a constructor?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you mean the fact that we have both a deferred and a promise, then the reason for that is that with V8 N-API cannot resolve a promise coming in from JavaScript, because it doesn't have the corresponding v8::Resolver.

In reality we could have gone with a single object, as @addaleax points out, but I chose not to because the coincidence between v8::Promise and v8::Promise::Resolver is an internal V8 detail and thus not guaranteed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I should have been more clear. It seems like these objects have a lot of different mechanisms for construction. Buffer (which I'm documenting) has four factory methods and two constructors. In the process of writing the documentation the factory methods seem clear, but I haven't quite understood the purpose of the public constructors. They seem like the end up putting the object into a weird (and potentially undesirable state).

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it's so compilation units written in C can interact with those written in C++?

Copy link
Member

Choose a reason for hiding this comment

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

@gabrielschulhof I don't think it was anything like that.

Copy link
Member

Choose a reason for hiding this comment

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

@kfarnung I'd suggest you ask @jasongin as he did a lot of the early work on the module.


* `[in] env`: The `napi_env` environment in which to construct the Reference object.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: extra whitespaces between list items

```

* `[in] env`: The `napi_env` environment in which to create the Deferred object.
Copy link
Contributor

@kfarnung kfarnung May 2, 2018

Choose a reason for hiding this comment

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

nit: looks like other docs use - (hyphen) for list items

@mhdawson
Copy link
Member

Going to land this and then we can improve through follow on PRs.

mhdawson pushed a commit that referenced this pull request Jun 14, 2018
PR-URL: #243
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
@mhdawson
Copy link
Member

Landed as 9d38f61

@mhdawson mhdawson closed this Jun 14, 2018
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
PR-URL: nodejs/node-addon-api#243
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
PR-URL: nodejs/node-addon-api#243
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
PR-URL: nodejs/node-addon-api#243
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
austinli64 added a commit to austinli64/node-addon-api that referenced this pull request May 9, 2023
PR-URL: nodejs/node-addon-api#243
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
PR-URL: nodejs/node-addon-api#243
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
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.

None yet

4 participants