Fork me on GitHub
#re-frame
<
2019-05-28
>
manutter5114:05:05

What do you all do when users hit the Reload button, and it blows away your app-db? Is there an elegant approach to preserving state across reloads?

miles22:05:11

I listen for the 'pagehide' event, and write the app-db to SessionStorage

manutter5123:05:09

Ah, that's interesting, I'll look into that, thanks!

manutter5114:05:04

I was thinking of hooking into onbeforeunload and persisting to local storage, but just wondered if there was something else people were doing.

lilactown14:05:10

should your state persist across reloads?

lilactown14:05:23

most of my apps don’t want that

manutter5114:05:36

Here’s one use-case: my app embeds an iframe to a 3rd-party app, and sometimes the 3rd-party app gets into a bad state, and you want a reload without losing your work in the main/host app.

lilactown14:05:15

sure, just nothing that the question should be asked first 😅

lilactown14:05:21

usually I only need to persist a subset of the actual app state. so what I do is write to local storage on mutation

lilactown14:05:41

but the onbeforeunload sounds nice too, since it won’t slow down your app while it’s running

dominicm15:05:06

@manutter51 could you put a reload button on the iframe?

manutter5115:05:12

We’ve got one actually, but you know muscle memory — you think reload, and boom Cmd-R and you’re done.