Skip to content

Instantly share code, notes, and snippets.

@shish
Created August 15, 2021 18:29
Show Gist options
  • Save shish/703e26676abb9ed56e21baee31c194d0 to your computer and use it in GitHub Desktop.
Save shish/703e26676abb9ed56e21baee31c194d0 to your computer and use it in GitHub Desktop.
Save hyperapp state across Parcel hot-module-reloads
let dispatch = app({...});
if (module && module.hot) {
module.hot.dispose(function (data) {
dispatch(function (state) {
data.saved_state = state;
return state;
});
});
module.hot.accept(function (getParents) {
dispatch(function (state) {
return module.hot.data.saved_state;
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment