Created
August 15, 2021 18:29
-
-
Save shish/703e26676abb9ed56e21baee31c194d0 to your computer and use it in GitHub Desktop.
Save hyperapp state across Parcel hot-module-reloads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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