简体   繁体   中英

How to call a reference function asynchronously, from N-api, I can not get “env”!

js code is:

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

remember function in c++:

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

when native function is called:

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

}

我使用node-addon-api解决了这个问题,现在我发现更新了napi,来自https://insight.io/github.com/nodejs/node/tree/master/test/addons-napi/test_env_sharing/ ,我认为有用!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM