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

AsyncWorker: make callback optional #489

Closed
wants to merge 1 commit into from

Conversation

KevinEady
Copy link
Contributor

@KevinEady KevinEady commented Jun 7, 2019

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)

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)
Copy link
Member

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.

Copy link
Contributor Author

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)
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

mhdawson pushed a commit that referenced this pull request Jun 18, 2019
`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 <michael_dawson@ca.ibm.com>
@mhdawson
Copy link
Member

Landed as b2b0812

@mhdawson mhdawson closed this Jun 18, 2019
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
`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 <michael_dawson@ca.ibm.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
`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 <michael_dawson@ca.ibm.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
`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 <michael_dawson@ca.ibm.com>
austinli64 added a commit to austinli64/node-addon-api that referenced this pull request May 9, 2023
`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 <michael_dawson@ca.ibm.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
`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 <michael_dawson@ca.ibm.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

2 participants