Serializing HyperFormula as Immutable Cell References #1325
Replies: 2 comments 6 replies
-
@BrianHung, I like the idea of a collaborative app on top of the HyperFormula engine. HyperFormula, though was not built with this in mind. The existing serialization/deserialization API does not preserve the entire state of the engine. It keeps only the current contents of the spreadsheet (think: copying and pasting the spreadsheet contents), omitting undo/redo stack, the structure of the dependency graph, and other internal data structures (address mapping, sheet mapping, etc). The unique ids that you're referring to exist only for the dependency graph nodes (actually, they were introduced only two months ago) and not for other components of the engine internal state. We would like to support your project, but we are operating on limited resources and cannot afford to rewire the whole HyperFormula to be more collaborative-friendly. I think that, for a start, we could introduce methods to serialize/deserialize the entire HyperFormula state (including undo/redo stack, preserving the unique ids of the dependency graph nodes, etc) and then start thinking about designing a more efficient way of synchronizing the state between multiple HyperFormula instances which is ultimately what would be required for a robust collaborative app. What do you think about it? Do you have other ideas of what API would be helpful for your project? |
Beta Was this translation helpful? Give feedback.
-
I'll leave it here as it's an interesting point and should be considered when designing a collaborative-friendly API: https://zknill.io/posts/collaboration-no-crdts/ |
Beta Was this translation helpful? Give feedback.
-
I've been exploring the HyperFormula codebase in an effort to implement a
formulasUpdated
event listener. The motivation for that listener was to sync different instances of HyperFormula for real-time collaboration.However, after learning that HyperFormula lazily resolves formulas
I've concluded that
formulasUpdated
isn't a performant way to sync cell values when there are large CRUD operations likeaddRow
.For example, if we had a 60,000 row spreadsheet with relative cell references, adding a row at the top would result in 60,000 formulas being updated.
The solution that I've seen implemented in HyperFormula internally and elsewhere is to use immutable cell references. HyperFormula does this with incrementing ids in its dependency graph.
However, these IDs are not persisted across instances—HyperFormula's serialization and deserialization process handles formulas with standard cell references, not immutable ones.
Is it possible to introduce an alternative API that supports initialization from, and deserialization to, immutable cell references?
Beta Was this translation helpful? Give feedback.
All reactions