Giter VIP home page Giter VIP logo

Comments (3)

mhdawson avatar mhdawson commented on June 8, 2024

In general I don't think it's safe to use something created with one env, in another env.

from abi-stable-node.

gabrielschulhof avatar gabrielschulhof commented on June 8, 2024

@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.

gabrielschulhof avatar gabrielschulhof commented on June 8, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.