node-addon-examples icon indicating copy to clipboard operation
node-addon-examples copied to clipboard

Add example that uses NODE_API_ADDON for addon registration

Open KevinEady opened this issue 2 years ago • 1 comments

It appears that all of our examples use the NODE_API_MODULE macro to register native addons. It would be helpful to add an example that uses NODE_API_ADDON registration, where the module extends Addon<T>.

KevinEady avatar Jun 24 '22 15:06 KevinEady

This issue was raised because of a question on node-addon-api on when to use which macro: https://github.com/nodejs/node-addon-api/issues/1190

KevinEady avatar Jun 24 '22 15:06 KevinEady

Hi,

I want to write a new Binding for openCV, and since I'm writing it from scratch, I want to make it as up-to-date as possible.

So I would like to use NODE_API_ADDON

My current sample code is here

the code builds fine, but my exported object is empty.

UrielCh avatar Mar 29 '23 13:03 UrielCh

This issue was resolved in https://github.com/nodejs/node-addon-examples/pull/209.

gabrielschulhof avatar Apr 08 '23 02:04 gabrielschulhof