reading from hyperformula when evaluation is suspended #1113
Replies: 4 comments 5 replies
-
@BrianHung Can you provide a code example that reproduces this issue? |
Beta Was this translation helpful? Give feedback.
-
Each HF method applies results immediately. If you have multiple changes, then those can be batched together. But not READ operation. Do you work with DOM? It's a similar idea to layout trashing. const oldWidth = DOMElement.width;
const oldHeight = DOMElement.height;
const oldPosX = DOMElemenet.left;
DOMElement.width = oldWidht + 100;
DOMElement.height = oldHeight + 200;
DOMElemenet.left = oldPosX + 300; is more performant than reading and writing at the same time: const width = DOMElement.width;
DOMElement.width = oldWidht + 100;
const height = DOMElement.height;
DOMElement.height = oldHeight + 200;
const posX = DOMElemenet.left;
DOMElemenet.left = oldPosX + 300; The moment you read something, you break the whole idea of batching. At its basics batching postpones all the operations that are required to read data (eval is equivalent to layout). The difference is that you have to "trash layout" manually 😉 -> Yes, it could be possible to return outdated values (before changes are applied), but it would require to store a copy of everything. Which in most cases is not necessary and super easy to do on your own. And IMO would be very confusing to users who could expect that they will get an updated value. Returning an information that you can't read while the evaluation is suspended is rather self explanatory // reading ops
const oldData = hf.getAllSheetsSerialized();
const fillDataBasedOnOldData = hf.getFillRangeData(source, target);
hf.suspendEvaluation();
// ... do your writing ops
hf.resumeEvaluation(); |
Beta Was this translation helpful? Give feedback.
-
@wojciechczerniak Thank you for the thorough explanation.
I created an issue for that: #1118 |
Beta Was this translation helpful? Give feedback.
-
@BrianHung We've just released the new version of our documentation with an updated Batch operations guide. |
Beta Was this translation helpful? Give feedback.
-
From the batching docs:
However, when trying to read from hyperformula, either through
getSheetSerialized
orgetFillRangeData
, I encountered an errorIs there a workaround for this? I have a general pattern of
Beta Was this translation helpful? Give feedback.
All reactions