Skip to content

Conversation

danielcompton
Copy link
Contributor

@danielcompton danielcompton commented Nov 22, 2017

This is not to be merged, but opening for discussion. It would be useful to be able to save a snapshot of app-state to be able to restore from later on, either within the same browser session or in a later one.

Current goals:

  • Serialise state and reload it within the same browser session
  • Serialise state and reload it against the same version of the application, but in a different session.

Out of scope:

  • Saving state from remote users and loading it into a debugging build
  • Exporting state
  • This working on different versions of code.

I found two issues immediately with the serialisation approach I have taken:

  • Some objects in app-db are not deserialisable, e.g. deftypes that haven't got a custom printer/reader.
  • In the todomvc example, there is a spec for the maps being ordered maps. However an ordered map serialised with prn is indistinguishable from a standard map and will cause a spec exception.

Both of these show that ser/de is likely to be the big blocker for this being a useful feature. I'm interested in hearing about other options here which can handle a wider range of datatypes than EDN.

One possibility is to use Transit and allow users to extend our transit readers and writers. I would probably prefer something more automatic but less compatible, like storing the memory representation and then reading it back. This is likely to be challenging for a variety of reasons though.

Another likely issue is being able to do some sort of pre and post initialisation, e.g. to synchronise localstorage, get new auth tokens, e.t.c.

@danielcompton
Copy link
Contributor Author

We now have the ability to walk backwards and forwards through state snapshots. Trying to reinstate the app-db state from localstorage is pretty difficult due to serialisation, for diminishing returns. Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant