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

188
Vistas
How to wait until all ViewModel formulas are done changing in ExtJS?

I'm working with the Ext JS framework. We have a fairly complex ViewModel with many formulas bound to other formulas. I'd like to be able to run some code only once the ViewModel has finished its long cascade of events triggering events. I'm trying to verify that, after all the ViewModel formulas have calculated, whether or not the data model remains identical to the expected values for the calculated fields returned from our API -- basically a deferred model.isDirty() check.

I've tried using setTimeout to add my event to the end of the event queue, but it sometimes ends up firing in the middle of the formula-updating cascade. I could simply set a longer timeout, but that feels kludgey, would force the user to wait longer, and can't be guaranteed to work on a particularly slow browser.

Is there a good way to run code as soon as the ViewModel is done calculating, and not a moment sooner?

Is there a way to check whether or not the ViewModel is done?

Is there a way to defer an event similarly to setTimeout, but to run only after the event queue becomes entirely empty?

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

0

I've solved my own problem.

In Ext JS version 7.3.1, you can inspect the scheduledCount member of the ViewModel's Scheduler, to find out whether any ViewModel formulae are waiting to run. If the value is zero, you can be sure the ViewModel has finished calculating.

const scheduler = this.getViewModel().getScheduler();

setTimeout(awaitViewModelFinished, 0);
function awaitViewModelFinished() {
    if (scheduler.scheduledCount > 0) {
        setTimeout(awaitViewModelFinished, 0);
        return;
    }

    // Payload code goes here.
}

I couldn't find a supported feature of the framework to do this. Per the sencha docs, "[Scheduler] is a private utility class for internal use by the framework. Don't rely on its existence." If you're using another Ext JS version, you may need to find a similar but different solution for this.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Inside the controller you can use:

// come viewModel options might not be resolved

this.getViewModel().notify();

// all viewModel options are solved

!!Careful: if a binding is null the bound formula won't run.

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