Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local state freezing in development #121

Closed
arctic-hen7 opened this issue Jan 20, 2022 · 4 comments
Closed

Local state freezing in development #121

arctic-hen7 opened this issue Jan 20, 2022 · 4 comments
Labels
author-willing-to-impl The author of this issue is willing to try to implement the solution themselves. C-enhancement Category: enhancement tribble-reported This issue was reported through Tribble.

Comments

@arctic-hen7
Copy link
Member

This issue is requesting an enhancement to Perseus. Details of the scope will be available in issue labels.
The user described the problem related to this request as follows:

Currently, developing Perseus apps can be irritating because you always lose your place. This is the problem HMR was designed to solve in the JS ecosystem, though it's widely accepted that this is basically impossible in the Wasm ecosystem until code-splitting and the like can be used without thousands of lines of glue code.

The user described the issue as follows:

With state freezing though, Perseus can support something even better than HMR, it can freeze the entire app's state and store it in IndexedDB or the like, allowing developers to keep their place even between full restarts of their computers. This is a nifty idea, but there is one problem. There will inevitably be cases in which something gets corrupted and the user wants to start afresh. We can support that by simply clearing the stored state and reloading the page, but we'll need some kind of button to let the user do this. From memory NextJS has a little state indicator that pops out of the side of the screen when you move your mouse near it, which could be quite good. Of course, all this would only be supported when the freeze feature is enabled, and only in development.

  • The author is willing to attempt an implementation: true
Tribble internal data

dHJpYmJsZS1yZXBvcnRlZCxDLWVuaGFuY2VtZW50LGF1dGhvci13aWxsaW5nLXRvLWltcGw=

@github-actions github-actions bot added author-willing-to-impl The author of this issue is willing to try to implement the solution themselves. C-enhancement Category: enhancement tribble-reported This issue was reported through Tribble. labels Jan 20, 2022
@lukechu10
Copy link
Contributor

It would be nice if this functionality could ultimately be built into sycamore itself because it sounds like sycamore apps not using perseus could benefit as well.

@arctic-hen7
Copy link
Member Author

Oh yeah that would be fantastic! The issue is that it requires a global state system, which Sycamore doesn't prescribe (and probably shouldn't). That said, it should be fairly easy to do if there were one, and I could build it as a separate library for caching a given struct to IndexedDB and fetching it out. That would make it as easy as possible to integrate into Sycamore in future as possible.

arctic-hen7 added a commit that referenced this issue Jan 29, 2022
arctic-hen7 added a commit that referenced this issue Jan 29, 2022
@arctic-hen7
Copy link
Member Author

HSR (Hot State Reloading) is now implemented!

@arctic-hen7
Copy link
Member Author

I've also eliminated the need for a little indicator by making the stored state simply clear itself after a CLi-initiated reload, which means the user can return to the original state by simply reloading, which is consistent with typical HMR behavior. This also avoids keeping old state for the next load when the user terminates the CLI process (the state from the last CLI-induced reload would be brought back up even several days later).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author-willing-to-impl The author of this issue is willing to try to implement the solution themselves. C-enhancement Category: enhancement tribble-reported This issue was reported through Tribble.
Projects
None yet
Development

No branches or pull requests

2 participants