Package Exports
- setimmediate-napi
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (setimmediate-napi) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
setimmediate-napi
setImmediate()
for N-API code
Installation
Install with npm
:
$ npm install setimmediate-napi
Usage
In your binding.gyp
:
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")",
"<!@(node -p \"require('setimmediate-napi').include\")"],
(Just have "<!@(node -p \"require('setimmediate-napi').include\")"
somewhere in that list, ok?)
In your C++ code:
#include <setimmediate.h>
int a = 10;
SetImmediate(env, [a]() {
/* do something with a ... */
});
Keep in mind:
- You need to use
Reference
s to keep track of JS objects, since this code runs asynchronously. - Use
MakeCallback
rather thanCall
to make sure Node.js can track your async context. - This function can be invoked even when executing JS code itself is not allowed.