Why do these two examples need a static FunctionReference?

Abierto
#169 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
45/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
cpp, nodejs

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C++
Estrellas
2.6k
Forks
602
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nodejs/node-addon-examples

Todos los issues de nodejs/node-addon-examples

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.