Hey there fellows. Lovely Monday to you all.
I need your feedback.
Currently I am developing an editor that edits some data which is stored in some sort of database (which is synced with the backend) while having its own local helper state. The database can be modeled as a Dict comparable EditableDataStructure
. Which element from the Dict
is used is determined by the Url
the user currently visits.
It is important to note that the Editor
has its own EditorState
which holds things like an UndoList
or an Html5.DragDrop.Model
which obviously not need to be saved in the EditableDataStructure
.
There are quite a few issues with this problem:
- Loading vs Referencing: When navigating to a Url I can either load the
EditableDataStructure
from myDict
into theEditorModel
or just reference thecomparable
.- Advantages of loading:
- It avoids mapping over
Maybe
for each update - The data is right there and slightly more performant to operate on
- It avoids mapping over
- Disadvantages of loading (that referencing does not have)
- The loaded and the persisted data may get out of sync.
- It violates the ‘single source of truth’ principle in elm
- Advantages of loading:
- Tracking
saved
state. How does the editor ensure that the state currently loaded is already persisted without making complex comparisons to the synced DB? Avoid syncing local and remote DB alltogether?
Did anyone here tackle a similar problem before?
Thank you for your feedback.