Why do these two examples need a static FunctionReference?

Aperta
#169 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
cpp, nodejs

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C++
Stelle
2.6k
Fork
602
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nodejs/node-addon-examples

Tutte le issue di nodejs/node-addon-examples

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.