Call Local<Function> with ObjectWrap as argument

Open
#50 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp, node.js
Domain
documentation

Research direction

Start with the Node.js addon examples and the ObjectWrap, Local, and Local API documentation named in the issue. Done means documenting a supported way to create an ObjectWrap-backed value and pass it to the persistent JavaScript callback without constructor round-tripping.

Written by the indexing model from the issue text.

Description

I cannot find any information on how to create an ObjectWrap and pass it as an argument to a Local. I have a persistent callback registered and need to call it with a new instance of an ObjectWrap. I could do this by calling the (JS) constructor and pass it (JS) arguments which returns a new instance, but I want to avoid this round tripping.

Basically: how to create an ObjectWrap and get a Local out of it so that I can pass it as an argument to a JS function?

Dominant language
C++
Stars
2.6k
Forks
602
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nodejs/node-addon-examples

All issues in nodejs/node-addon-examples

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.