Why do these two examples need a static FunctionReference?
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- cpp, nodejs
- Domain
- backend-api-design
Research direction
Read function-reference-demo/node-addon-api/src/native-addon.cc and inherits_from_event_emitter/node-addon-api/src/native-emitter.cc, focusing on the static FunctionReference declarations in Init. Compare them with the instance-data change in commit dc86a662c27c5732e069e1c19d3b7a8e74e86d29. Done means the examples no longer retain unnecessary constructor references while continuing to build and work.
Written by the indexing model from the issue text.
Description
https://github.com/nodejs/node-addon-examples/blob/c1bdff050f8c7dc250f7779283fbab664bfb5bcd/function-reference-demo/node-addon-api/src/native-addon.cc#L4
https://github.com/nodejs/node-addon-examples/blob/c1bdff050f8c7dc250f7779283fbab664bfb5bcd/inherits_from_event_emitter/node-addon-api/src/native-emitter.cc#L7
It's not referred anywhere other than the Init function and having an "immortal" Napi::FunctionReference seems unnecessary since the constructor isn't invoked from native code.
Curiously, these two examples were untouched by dc86a662c27c5732e069e1c19d3b7a8e74e86d29, which replaced the usage of a static FunctionReference with instance data in examples that do need to keep the constructor alive.
- Dominant language
- C++
- Stars
- 2.6k
- Forks
- 602
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nodejs/node-addon-examples
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 38/100
nodejs/node-addon-examples#585 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
nodejs/node-addon-examples#530 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
nodejs/node-addon-examples#445 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 32/100
nodejs/node-addon-examples#444 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
nodejs/node-addon-examples#381 ·
All issues in nodejs/node-addon-examples
Similar issues
-
Website Doc Typo Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
autowarefoundation/autoware_universe#13413 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
automated-analysis bug memory-safety
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100