Loading Data into an Editor with additional state

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 my Dict into the EditorModel or just reference the comparable.
    • Advantages of loading:
      • It avoids mapping over Maybe for each update
      • The data is right there and slightly more performant to operate on
    • 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
  • 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.

I think the disadvantages of loading far outweigh the advantages here. Are you sure the performance is relevant for your usecase?

In case you have not seen it yet, maybe this talk by Richard can give you some more ideas:
Immutable Relational Data

Thank you! I refactored the app right after and it’s a lot more maintainable now.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.