-
Notifications
You must be signed in to change notification settings - Fork 465
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
doc: update ObjectWrap example #754
doc: update ObjectWrap example #754
Conversation
28e53d1
to
6252e48
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.
Just one thing to do. The rest seems good.
doc/object_wrap.md
Outdated
// Retrieve the instance data we stored during `Init()`. We only stored the | ||
// constructor there, so we retrieve it here to create a new instance of the | ||
// JS class the constructor represents. | ||
Napi::FunctionReference* constructor = info.Env().GetInstanceData<Example>(); |
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.
It should be:
Napi::FunctionReference* constructor = info.Env().GetInstanceData<Napi::FunctionReference>();
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.
You're right! Good catch! Thanks!
* Remove the global static reference to the constructor * Use `Napi::Env::SetInstanceData` to store the constructor, and * Add a static method that uses `Napi::FunctionReference::New` to create a new instance of the class by retrieving the constructor using `Napi::Env::GetInstanceData` and using `Napi::FunctionReference::New` to create the new instance. Fixes: nodejs#711
6252e48
to
e095c01
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.
LGTM
* Remove the global static reference to the constructor * Use `Napi::Env::SetInstanceData` to store the constructor, and * Add a static method that uses `Napi::FunctionReference::New` to create a new instance of the class by retrieving the constructor using `Napi::Env::GetInstanceData` and using `Napi::FunctionReference::New` to create the new instance. Fixes: #711 PR-URL: #754 Reviewed-By: Nicola Del Gobbo <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Landed in ef16dfb. |
* Remove the global static reference to the constructor * Use `Napi::Env::SetInstanceData` to store the constructor, and * Add a static method that uses `Napi::FunctionReference::New` to create a new instance of the class by retrieving the constructor using `Napi::Env::GetInstanceData` and using `Napi::FunctionReference::New` to create the new instance. Fixes: nodejs/node-addon-api#711 PR-URL: nodejs/node-addon-api#754 Reviewed-By: Nicola Del Gobbo <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
* Remove the global static reference to the constructor * Use `Napi::Env::SetInstanceData` to store the constructor, and * Add a static method that uses `Napi::FunctionReference::New` to create a new instance of the class by retrieving the constructor using `Napi::Env::GetInstanceData` and using `Napi::FunctionReference::New` to create the new instance. Fixes: nodejs/node-addon-api#711 PR-URL: nodejs/node-addon-api#754 Reviewed-By: Nicola Del Gobbo <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
* Remove the global static reference to the constructor * Use `Napi::Env::SetInstanceData` to store the constructor, and * Add a static method that uses `Napi::FunctionReference::New` to create a new instance of the class by retrieving the constructor using `Napi::Env::GetInstanceData` and using `Napi::FunctionReference::New` to create the new instance. Fixes: nodejs/node-addon-api#711 PR-URL: nodejs/node-addon-api#754 Reviewed-By: Nicola Del Gobbo <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
* Remove the global static reference to the constructor * Use `Napi::Env::SetInstanceData` to store the constructor, and * Add a static method that uses `Napi::FunctionReference::New` to create a new instance of the class by retrieving the constructor using `Napi::Env::GetInstanceData` and using `Napi::FunctionReference::New` to create the new instance. Fixes: nodejs/node-addon-api#711 PR-URL: nodejs/node-addon-api#754 Reviewed-By: Nicola Del Gobbo <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Napi::Env::SetInstanceData
to store the constructor, andNapi::FunctionReference::New
tocreate a new instance of the class by retrieving the constructor
using
Napi::Env::GetInstanceData
and usingNapi::FunctionReference::New
to create the new instance.Fixes: #711