如何异步调用引用函数,从N-api,我无法得到" env"!

时间:2017-07-10 05:54:41

标签: node.js node.js-addon node.js-napi

js代码是:

const obj = tap.create();
quote.on("connection", (params) => {
console.log('[DEBUG js]', 'connection called, params:', params);
});

记住c ++中的函数:

napi_create_reference(env, args[1], 1, &cbMap[eIt->second]);

调用本机函数时:

void TAP_CDECL Spi::OnConnect(int errorCode, const Info *info) {

{{I want to call the function from cbMap here, How to write code? I do not 
known how to find "env"!}}

}

1 个答案:

答案 0 :(得分:0)

我使用node-addon-api解决问题,现在我发现napi已更新,来自https://insight.io/github.com/nodejs/node/tree/master/test/addons-napi/test_env_sharing/,我觉得它很有用!