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

289
Views
Eventlistener function is undefined?

When a button is clicked I want the event listener to be removed.

function clickMe(f,i){
      ipcRenderer.send('click', i)

      ipcRenderer.on(`message`, function (en, message) {
        document.getElementById(`status${i}`).innerHTML = message[1];
        //ipcRenderer.removeAllListeners('message') <- I don't want all listeners to be removed
      });
}

As shown in the code above, removeAllListeners works, however, I do not want all listeners to be removed. I believe I can use removeListener('message', function) but if I try to put removeListener('message', startMe()) I get thrown an error of undefined. How would I go abouts doing this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The method is called removeEventListener which takes the function you want to remove as its second parameter. You can't remove it, because the function is anonymous. If you use named functions, it should work:

function onMessage = function (en, message) {
    document.getElementById(`status${i}`).innerHTML = message[1];
    ipcRenderer.removeEventListener('message', onMessage);
}

function clickMe(f,i){
      ipcRenderer.send('click', i)
      ipcRenderer.on('message', onMessage);
}
about 4 years ago · Juan Pablo Isaza 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!