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

Add a helper to enable hot-reloading of the preview-frame. #202

Merged
merged 2 commits into from
Jan 20, 2023

Conversation

tomprince
Copy link
Contributor

@tomprince tomprince commented Jan 17, 2023

This uses undocumented hook mentioned in sveltejs/svelte-hmr#57 to automatically update the
preview frame, when the preview frame gets reloaded.

@resonant-gamedesign
Copy link
Collaborator

Can you explain what this is doing? What is "on:hot-reload" and when will that trigger?

@tomprince
Copy link
Contributor Author

Can you explain what this is doing? What is "on:hot-reload" and when will that trigger?

When using npm run dev, that runs a local web server that serves the app. That server is intended for being used while editing the app, so it has some features to make that process smoother. In particular, when you make a change to a file (and save it), the server notices that and tells the browser to update that bit of code. The easiest way would be to just refresh that page, but that is more disruptive than necessary a lot of the time. In practice, what happens is that when a component is updated, just that component is recreated (see here for a discussion of some of the details). That doesn't work for the preview frame, as it will just be empty. This adds some hooks for adding to that behaviour. In particular, after the preview frame is recreated, we now update the preview.

@resonant-gamedesign
Copy link
Collaborator

resonant-gamedesign commented Jan 20, 2023 via email

@tomprince
Copy link
Contributor Author

I also added in a cleanup of an unused variable that was accidentally left in #157.

@neubee neubee merged commit 23cecbb into spirit-island-builder:dev Jan 20, 2023
@tomprince tomprince deleted the hot-reload-fixes branch February 21, 2023 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants