2017-07-10 42 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/,我認爲它很有用!