2017-07-10 24 views
1

JS代码是:如何从N-API异步调用引用函数,我无法获得“env”!

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"!}} 

} 

回答

0

我使用节点 - 附加API解决这个问题,现在我发现napi更新了,从https://insight.io/github.com/nodejs/node/tree/master/test/addons-napi/test_env_sharing/,我认为它很有用!