Open LeaVerou opened 3 years ago
This sounds like micromanagement, and the name sounds like a static thing (like expressions would never recalculate, so why have them?)
Perhaps a bigger picture sort of approach, like lazy
or late
or batch
or calc-after-save
or something that the user doesn't have to understand what's going on...
I was thinking of this proposal, and it hit me that I've already seen something similar in spreadsheets: since workbooks might have a huge amount of data with a bunch of formulas inside them, that might tremendously slow down their recalculation. That's why spreadsheets provide a way to control how often recalculations should happen. Even though they give users a slightly different set of options, the idea is clear.
Google Sheets:
Microsoft Excel:
We can also find a similar feature on Codepen:
What if we could let authors control the process of expressions recalculation via an attribute provided on an app's root? And if an author decides to recalculate expressions manually, we could add a button (i.e., Calculate
) on the Mavo bar.
@DmitrySharabin Interesting observation. It's always good food for thought to look at what spreadsheets do. However, that wouldn't solve the use cases I had in mind, because for those I want expression recalculation to happen instantly, just not across the whole tree.
Also note that Mavo (unfortunately) does not distinguish between a step in a calculation and an expression recalculation triggered by a change. So with the current architecture, if we implemented something like this, we'd end up with expressions that are incompletely calculated.
That said, I really want to do a Big Expressions Rewrite™ at some point and fix that and many other issues around expression (re)calculation.
This is more of a performance hint, but hey, even CSS is adding those by the kilo these days.
In cases where an app has a lot of data (e.g. my migraine app), I've often resorted to using separate pages to prevent adding new data entries from slowing down the interface because it's recalculating all the expressions. Even expressions in
mv-if
need to recalculate, because in theory they may be needed to re-enable themv-if
. Similarly, expressions in hidden subtrees may still be referenced elsewhere, so still need to recalculate.Even Mavo itself uses this approach sometimes. E.g. when rendering a collection, expressions are disabled on the collection temporarily, then all are recalculated together at the end.
I'm thinking about adding an
mv-expressions-disable
attribute that will disable expression update on the subtree it is added until it's removed. When it's removed, all expressions inside it will update at once, to make sure they're not stale.I think this will be useful in large apps that use the JS API so they can hide large chunks of Mavo and disable expressions until that part is ready to be displayed.
Thoughts?