Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
JavaScript calling function 4 times but I need to execute function only one time

I have listener when any change in volume execute callback function 4 times callback call other function I need that function execute only one what is the best way

when lisiner detect any change callback call recognitionCameraBySoundVolum() 4 time

volumeListener = SystemSetting.addVolumeListener((data) => { 
    recognitionCameraBySoundVolum();
});

need to excute this function only once instead of 4

   const recognisionCameraBySoundVolum = () => {
        console.log("hi from recognitionCameraBySoundVolum "); 
    }
about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

Did you use the useEffect hook?

It should look something like this.

useEffect(() => {
    volumeListener = SystemSetting.addVolumeListener((data) => { 
        recognitionCameraBySoundVolum();
    });

    // return remove listener method in the cleanup section 
}, []);
about 4 years ago · Santiago Gelvez Denunciar

0

this worked with me

useEffect(() => {
const volumeListener = SystemSetting.addVolumeListener( (data) => { 
    const volume = data.value;  

}); 
return () => 
SystemSetting.removeVolumeListener(volumeListener)  
}, [])
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda