$ cnpm install setimmediate-napi
setImmediate() for N-API codeInstall with npm:
$ npm install setimmediate-napi
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:
References to keep track of JS objects, since this code runs asynchronously.MakeCallback rather than Call to make sure Node.js can track your async context.Copyright 2013 - present © cnpmjs.org | Home |