It might be a really stupid idea.
But thinking more functionally, we always take a model and return a new model,
Could we somehow take the whole localState object and produce a new localState object ?
Read Once:
Browser.Storage.getLocalStorage or Browser.Storage.getSessionStorage
Read storage once, manipulate it like a normal model in Elm during the app’s lifetime, and then overwrite the whole thing every time you need to persist it.
If there comes a time during the app’s life, where you want to persist storage, you have a Cmd with Browser.Storage.persistLocalStorage and hands it (Dict String String) from your model.
In most cases, you only need to store before refresh and before page close ?
Subscriptions model =
Browser.Events.onUnload UnloadMsg