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

173
Vistas
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 Respuestas
Responde la pregunta

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 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