Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

avoid global redraw on modular view model

Tags:

mithril.js

how would I be able to avoid a global redraw = call to the main view function while changing the view of a submodule like in the main Module view method:

m("body", [
           m("#head", {...}),
           Menu.show(this),
           Footer.show(this)
])

where the static show method looks like :

    function show(app)
    {
        if (inst == null)
            inst = new Footer(app);
        return inst.view(app);
    }

Now it should increase the already nice performance if there is a way to run the view method of a sub view without running the main view method in case the changes in the sub view have only local effects. Does this make sense?

Axel

like image 204
Axel Huizinga Avatar asked Dec 03 '25 14:12

Axel Huizinga


1 Answers

You can't prevent a global redraw, but you can selectively make some parts of the view not redraw by using subtree directives

Be aware however that this is a performance optimization that disables redrawing for the affected subtree, and as such, you won't be able to update its view unless you replace the directive with a subtree again.

like image 153
LeoHorie Avatar answered Dec 06 '25 14:12

LeoHorie