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

Live Reloading #727

Merged
merged 6 commits into from
May 27, 2024
Merged

Live Reloading #727

merged 6 commits into from
May 27, 2024

Conversation

bjornbytes
Copy link
Owner

@bjornbytes bjornbytes commented Dec 4, 2023

This adds live reloading! You can use the --watch or -w command line flag to watch files in the source folder for changes. The watching uses efficient native APIs (inotify, FSEvent, IOCP).

When a file is changed, the lovr.filechanged event will be called with the file path and the type of change (create, delete, modify, rename). The default implementation of lovr.filechanged will simply call lovr.event.restart to reload the project, but projects can override the callback to filter paths or add more fine-grained reloading logic (like hotswapping assets without doing a full restart).

Use -w or --watch to watch source directory for changes and call
lovr.filechanged when a file is changed.

By default lovr.filechanged will restart lovr.

It's powered by lovr.filesystem.watch/lovr.filesystem.unwatch functions,
but these are currently hardcoded to only watch the whole source folder.

Currently there is a bug where it only restarts on the first change,
this is seemingly a problem with dmon.
Stale state prevented library from working when reinitialized.
Another solution might be retain/release.
@bjornbytes bjornbytes merged commit 4ba215a into dev May 27, 2024
8 checks passed
@bjornbytes bjornbytes deleted the watch branch May 27, 2024 11:27
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.

None yet

1 participant