Open AMBudnik opened 1 year ago
Reposting from discussions: https://github.com/handsontable/hyperformula/discussions/1155
It would be useful to have a formulasUpdated
listener, as mentioned in #135.
I've been trying to integrate hyperformula with an external data source (to work with React etc), and have noticed that some methods like addRow
and moveRows
modify internal formula representations.
Essentially the same problem that handsontable faces in https://github.com/handsontable/handsontable/issues/8114, where you can move rows and columns but formulas referencing values in those moved rows or columns are now out of date.
For example if we had a =SUM(A1:B3)
and the third row was deleted, the formula would be changed to =SUM(A1:B2)
.
Right now the only way to correctly react to changes in formulas is to use getAllSheetsSerialized
.
However, this isn't as efficient as valuesUpdated
is for listening to changes in values, since there can be a lot of sheets and would cause excessive re-rendering without manual diffs (which is also expensive).
This is a complex task which requires redesigning some parts of the core functionalities. Also it could affect the performance of the engine. As @swistak35 wrote in https://github.com/handsontable/hyperformula/issues/135#issuecomment-593164908:
I've decided to not do it immediately because it needs significant work, so I wanted to double-check, how much we need that event right now. This is because currently we have an optimization, so we don't update the formula immediately after CRUD operations, but only when we need that formula for recomputation (or for any other case, like when user asks for it). Instead of immediate computation, we do that lazily -- it's not so easy to track these changes and we would need to do some refactoring.
If we want to proceed with this feature, we should start with a research/POC task with the aim to find out how much effort it requires and what impact on performance it has.
Description
We should consider:
formulasUpdated
event that can be subscribed toThe
formulasUpdated
hook was described in this issue https://github.com/handsontable/hyperformula/issues/135#issue-556160779. The issue, was close as done without introducing the hook so I've created a separate issue.Pre-hook description
Related issues/discussions: