Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!