Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
How to remove event listener or emitter listeners in React Native

I am trying to remove an event listener. The old way is deprecated. We are told to use .remove(). I am not sure how to refactor my code to do so. I am using a class component.

Can you provide an example of how to remove event listener. Currently my event listener is inside of another function. I have it that way as I may need to create another event listener every time the button is press and I need to remove the listener after the function runs.

startProcess = (result) => {
  //  stuff for running process
  console.log("your function is running its process");

  //deprecated but easy way to remove the event listener below
  // eventEmitter.removeListener('PreparePaywallFinished', onPreparePaywallFinished);

  //new way to remove event listen use remove() method on the EventSubscription returned by addEventListener()
  this.subscribeStartProcess.remove;
};

handleBtnPress = () => {
  // the listener
  eventEmitter.addListener("onMidiStart", this.startProcess);

  // emitter
  NativeModules.midiBridgeStart(true, 2);
};

render(){
  return <Button title='press' onPress={()=> handleBtnPress() />
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use

window.removeEventListener('onMidiStart', handleonMidiStart);

the second argument in the removeEventListener is a variable to identify which event listed is being removed . A detailed description is being given here enter link description here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda