How to use the mithril.startComputation function in mithril

To help you get started, we’ve selected a few mithril examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github barneycarroll / mithril.exitable.js / src / exitable.es6.js View on Github external
const exits    = []

      // For every previous exitable instance...
      for( let [ ctrl, el ] of previous )
        // ...if it hasn't re-registered...
        if( !roots.has( ctrl ) )
          // It's gone! Call the exit method and keep its output.
          exits.push( ctrl.exit( el ) )

      // If we have exits...
      if( exits.length ){
        // Noop this draw
        output = { subtree : 'retain' }

        // Freeze the draw process
        mithril.startComputation()

        // ...until all exits have resolved
        Promise.all( exits ).then( () => {
          // We now need to revert Mithril's internal virtual DOM head so that
          // it will correctly patch the live DOM to match the state in which
          // components are removed: it currently believes that already happend
          // Because it ran the diff before we told it to retain the subtree at
          // the last minute
          reverting = true

          // Next draw should not patch, only diff
          mithril.redraw.strategy( 'none' )

          // Force a synchronous draw despite being frozen
          mithril.redraw( true )
github akx / glitch2 / glitcher / ui.js View on Github external
export function init(engine) {
  const uiContainer = document.createElement('div');
  uiContainer.id = 'ui-container';
  document.body.appendChild(uiContainer);
  m.startComputation();
  const ctrl = m.module(uiContainer, { controller, view });
  ctrl.engine = engine;
  m.endComputation();
}
github gitter-badger / moria / moria.js View on Github external
controller : function redirection(){
				var endpoint = to.replace( paramToken, function insertParam( token, param ){
					return m.route.param( param );
				} );

				m.startComputation();

				m.route( endpoint );

				m.endComputation();
			},
			view       : emptyView
github wikipathways / pvjs / src / editor / dataset-selector.js View on Github external
function promisify(highlandStream) {
    //tell Mithril to wait for this service to complete before redrawing
    m.startComputation();
    var deferred = m.deferred();

    highlandStream.toArray(function(results) {
      deferred.resolve(results);
      //the service is done, tell Mithril that it may redraw
      m.endComputation();
    });

    return deferred.promise;
  }
github RetroShare / RetroShare / libresapi / src / webui-src / app / retroshare.js View on Github external
m.sync(requests).then(function trigger_render(){
            m.startComputation();
            m.endComputation();
            checkFocus();
        });
    });
github RetroShare / RetroShare / libresapi / src / webui-src / app / adddownloads.js View on Github external
function refresh(){
    m.startComputation();
    m.endComputation();
}
github APE-EDX / APE / public / components / project.js View on Github external
var scanProjects = function(config) {
    ipcRenderer.send('scan-projects', config.projectFolder);
    m.startComputation();
}