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

128
Vistas
Code Mirror 6 & React component on update re-subscribe after CM6 state reset

I recently started playing with CM6 and got stuck at a react component which contains tabs each pointing to separate text/code. On tab click, I reset CM6 state. On the init of the component, I register an event listener via:

extensions.unshift(EditorView.updateListener.of(onUpdate))

Now after a user clicks on a different tab/file I reset the editor via:

view?.setState(
    EditorState.create({
      doc: resetValue,
      selection,
      extensions: [mySetup, EditorView.updateListener.of(onUpdate)],
    }),

I reset since I do not want to mix the history between the different "files". After the reset, I can not get the onUpdate to fire with the proper context. It always points to the original. In other words, any values in the onUpdate definition outside of that handler are not current.

I am trying to understand how can I unregister the initial onUpdate and register it again in the extensions on reset? I tried something like this:

 view?.dispatch({
      effects: StateEffect.reconfigure.of([EditorView.updateListener.of(onUpdate)]),
 });

Any help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The steps were correct.

 view?.dispatch({
      effects: StateEffect.reconfigure.of([EditorView.updateListener.of(<YOUR FN>)]),
 });

Will take care of the re-subscription

The issue was a closure on one of my functions.

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