New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch operations #18
Comments
Looks like it's not finished and some TODOs left: hyperformula/src/HyperFormula.ts Lines 799 to 806 in be57f95
It's confusing that inside Also, it's not clear how nested engine.batch(evaluator => {
evaluator.setSheetContent('Sheet1', [ ... ] )
evaluator.setSheetContent('Sheet2', [ ... ] )
evaluator.setSheetContent('Sheet3', [ ... ] )
}) the I think we may have public recalculate() {
this.recomputeIfDependencyGraphNeedsIt()
} Then we have to extend it with an argument to force recalculation. And extend the API What I've missed before is that for complex sheets there is an option to disable recalculation on change and to it on demand. To integrate such a feature we will need We were thinking about similar solution for rendering in Handsontable, so a short pseudo-code: public batch(callback) {
this.suspendEvaluation()
callback()
this.resumeEvaluation()
this.recalculate()
} This way we can have a toolbar with "calculate on change" toggle and "recalculate" button. Just like a full spreadsheet app has. API requiredInspired by XL public suspendEvaluation(): void
public resumeEvaluation(): void
public isEvaluationSuspended(): boolean
public recalculate(force?: boolean): Changes[]
public rebuildAndRecalculate(): Changes[]
public batch(callback: function): Changes[] |
Additional config option |
@wojciechczerniak I think there are a couple of alternatives:
(2) sounds annoying, (3) is big task, so maybe we can start with (1) and leave other as options for future? |
Note: We've agreed to proceed with the first solution idea. The integrator can use API to get all the values and cache them. No need for us to keep everything inside the engine. |
I think with #256 it's all here? There's an option to remove IBatchExecutor but that will be part of my changes on route to making undo redo work. I think I've done all relevant methods from proposed API, with the change that "resume" immediately recalculates (in order to not have the state where we have "resumed" computation but it is not recomputed). Resuming returns all changes, so that should be enough. And regarding rebuilding (rebuilding formulas after CRUD operations), we've agreed that it happens always and there's no option to stop it. |
Yup, we've got everything we need. Thx 🥇 Note to future self: It's easy to implement XL style "Calculate" on-demand button. No need for public API. Just resume (aka recalculate) and suspend again so the app stays in suspended state. function recalculate() {
const changes = hf.resume()
hf.suspend()
return changes
} |
Description
There is no point in evaluating every CRUD operation, every data change if we know that more fields are going to change their values. Formulas evaluation should be triggered at the end of the process.
Sometimes developers want to trigger recalculation only on demand. I.e. by the user pressing a button within their application. This is similar to other spreadsheet software when the user (or developer) can switch operation mode when she expects many time-consuming worksheets.
Smart recalculation
The default operation mode of Handsontable.
batch
methodBy @bardek8
But it would break the operations if it's not possible to apply one of them. A user wouldn't know which one was applied and which failed.
Manual calculation mode
In manual calculation mode all CRUD operations do not trigger calculations.
We can do it through API:
recalculate()
recalculate(force = true)
rebuildAndRecalculate()
And add keyboard shortcuts that are familar to our users.UI / HandsontableThe text was updated successfully, but these errors were encountered: