Sitelet https://web.archive.org/web/20201231110629/https://github.com/nodejs/node-addon-examples/issues/82
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

Need an example of using napi_create_async_work() #82

Open
gabrielschulhof opened this issue Nov 2, 2017 · 8 comments
Open

Need an example of using napi_create_async_work() #82

gabrielschulhof opened this issue Nov 2, 2017 · 8 comments

Comments

@gabrielschulhof
Copy link
Contributor

@gabrielschulhof gabrielschulhof commented Nov 2, 2017

nodejs/node#13512 seems to indicate that we should have such an example.

@Globik
Copy link

@Globik Globik commented Jan 5, 2018

There it is on nodejs repo test napi. But bug or not a bug. Process crashes when invoking the same async function twice and more times. Did you tried their sample on your comp?

@Globik
Copy link

@Globik Globik commented Jan 5, 2018

By the way here is a simplified example of napi create async work:
https://github.com/Globik/libqrencode-js/blob/master/simple_test/test_async.c
In pure C.

NickNaso referenced this issue in NickNaso/abi-stable-node-addon-examples Mar 2, 2018
mhdawson referenced this issue in nodejs/abi-stable-node-addon-examples Apr 26, 2018
Porting asynchronous example from NAN repo.
The original example is hosted here:
https://github.com/nodejs/nan/tree/master/examples/async_pi_estimate.
Rewrite all the logic using **node-addon-api** See the following
issue https://github.com/nodejs/abi-stable-node-addon-examples/issues/10

Added examples for event emitter
See: nodejs/node-addon-api#110
mhdawson referenced this issue in nodejs/abi-stable-node-addon-examples Apr 26, 2018
Porting asynchronous example from NAN repo.
The original example is hosted here:
https://github.com/nodejs/nan/tree/master/examples/async_pi_estimate.
Rewrite all the logic using **node-addon-api** See the following
issue https://github.com/nodejs/abi-stable-node-addon-examples/issues/10

Added examples for event emitter
See: nodejs/node-addon-api#110
@Globik
Copy link

@Globik Globik commented May 19, 2018

Emit event from cpp is good, but how to the same with a pure c's node_api.h?

@Globik
Copy link

@Globik Globik commented May 20, 2018

If you are wandering about how to emit an event from plain C to node.js:
https://github.com/Globik/kore-mediasoup/tree/master/addon/emitter

@mhdawson
Copy link
Member

@mhdawson mhdawson commented May 25, 2018

@Globik it would be great if you could create examples that could be added to: https://github.com/nodejs/abi-stable-node-addon-examples

@Globik
Copy link

@Globik Globik commented Jun 15, 2018

@mhdawson how to do it? Do I need a pull request with examples?

@mhdawson
Copy link
Member

@mhdawson mhdawson commented Jun 18, 2018

@Globik you can create PR that adds the example to that repository.

@Globik
Copy link

@Globik Globik commented Jun 18, 2018

@mhdawson and the sample like this will do? Glib loop in a dedicated thread within nodejs addon N-API:
https://github.com/Globik/kore-mediasoup/blob/master/addon/emitter5/uv_glib.c

@mhdawson mhdawson transferred this issue from nodejs/abi-stable-node-addon-examples Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.