-
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
AsyncWorker: make callback optional #489
Conversation
napi-inl.h
Outdated
@@ -3522,6 +3522,32 @@ inline AsyncWorker::AsyncWorker(const Object& receiver, | |||
NAPI_THROW_IF_FAILED_VOID(_env, status); | |||
} | |||
|
|||
inline AsyncWorker::AsyncWorker(napi_env env) |
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.
These should be Napi::Env env
as opposed to napi_env env
for consistency with the rest of the API. Same goes for other places env is being added.
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.
Thanks for the tip. I was a little confused because several places use napi_env
but maybe those are older pieces of code. Changed now to Napi::Env
`AsyncWorker` assumed that after work is complete, a JavaScript callback would need to execute. This change removes the restriction of specifying a `Function` callback, and instead replaces it with an `Env` parameter. Since the purpose of `receiver` was for the `this` context for the callback, it has also been removed from the constructors. Re: nodejs#231 (comment)
1b0aa83
to
1159aeb
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
`AsyncWorker` assumed that after work is complete, a JavaScript callback would need to execute. This change removes the restriction of specifying a `Function` callback, and instead replaces it with an `Env` parameter. Since the purpose of `receiver` was for the `this` context for the callback, it has also been removed from the constructors. Re: #231 (comment) PR-URL: #489 Reviewed-By: Michael Dawson <[email protected]>
Landed as b2b0812 |
`AsyncWorker` assumed that after work is complete, a JavaScript callback would need to execute. This change removes the restriction of specifying a `Function` callback, and instead replaces it with an `Env` parameter. Since the purpose of `receiver` was for the `this` context for the callback, it has also been removed from the constructors. Re: nodejs/node-addon-api#231 (comment) PR-URL: nodejs/node-addon-api#489 Reviewed-By: Michael Dawson <[email protected]>
`AsyncWorker` assumed that after work is complete, a JavaScript callback would need to execute. This change removes the restriction of specifying a `Function` callback, and instead replaces it with an `Env` parameter. Since the purpose of `receiver` was for the `this` context for the callback, it has also been removed from the constructors. Re: nodejs/node-addon-api#231 (comment) PR-URL: nodejs/node-addon-api#489 Reviewed-By: Michael Dawson <[email protected]>
`AsyncWorker` assumed that after work is complete, a JavaScript callback would need to execute. This change removes the restriction of specifying a `Function` callback, and instead replaces it with an `Env` parameter. Since the purpose of `receiver` was for the `this` context for the callback, it has also been removed from the constructors. Re: nodejs/node-addon-api#231 (comment) PR-URL: nodejs/node-addon-api#489 Reviewed-By: Michael Dawson <[email protected]>
`AsyncWorker` assumed that after work is complete, a JavaScript callback would need to execute. This change removes the restriction of specifying a `Function` callback, and instead replaces it with an `Env` parameter. Since the purpose of `receiver` was for the `this` context for the callback, it has also been removed from the constructors. Re: nodejs/node-addon-api#231 (comment) PR-URL: nodejs/node-addon-api#489 Reviewed-By: Michael Dawson <[email protected]>
AsyncWorker
assumed that after work is complete, a JavaScript callback would need to execute.This change removes the restriction of specifying a
Function
callback, and instead replaces it with anEnv
parameter. Since the purpose ofreceiver
was for thethis
context for the callback, it has also been removed from the constructors.Re: #231 (comment)