Comments (3)
In general I don't think it's safe to use something created with one env, in another env.
from abi-stable-node.
@cutsoy I agree with @mhdawson. It would be safer for modules foo
and bar
to coordinate via JS. For example, module bar
can expose a function that receives as its sole parameter the desired object. Then, the function can be passed into module foo
, which will call it with the object. Module bar
can then create a second reference to the same object. So, roughly,
foo.sendObject(bar.receiveObject);
where sendObject
is implemented as
static napi_value SendObject(napi_env env, napi_callback_info info) {
napi_value cb, the_object;
size_t argc = 1;
napi_get_cb_info(env, info, &argc, &cb, NULL, NULL);
napi_get_reference_value(env, the_object_ref, &the_object);
napi_call_function(env, the_object, cb, 1, &the_object, NULL);
}
from abi-stable-node.
@cutsoy I hope this answers your question. If you have any further questions, please feel free to re-open this issue or open a new one.
from abi-stable-node.
Related Issues (20)
- Ask for review of node-serialport Node-API port - https://github.com/serialport/node-serialport/pull/2305/files HOT 2
- Drive towards full coverage HOT 5
- Discuss Node-API addition https://github.com/nodejs/node/pull/41329#issuecomment-1015667899 HOT 1
- Regular hang in Running test 'typed_threadsafe_function/typed_threadsafe_function_sum' HOT 1
- Node-API v9 HOT 7
- Better coverage of node-api in Youtube HOT 13
- Node-API add-on build HOT 4
- Add list of non C language bindings to Node.js doc HOT 10
- Document how to check for memory leaks in addon/default leak. HOT 4
- Electron 21 breaks api compatability with some modules HOT 9
- Get contacts for each of the runtimes supporting Node-API HOT 8
- What's new in the Node-API and node-addon-api world? - 2023 version HOT 20
- Improve score on OpenSSF scorecard HOT 8
- Consider changing the license for examples to MIT HOT 2
- Tracking issues for V8 changes needed HOT 1
- Help with node-sqlite3 performance HOT 3
- What's new in the Node-API and node-addon-api world? - 2024 version HOT 3
- Discuss reverting nogc commits HOT 1
- Warn/print message when NAPI_EXPERIMENTAL is used in a build HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abi-stable-node.