-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
[WIP] Hot reloading #930
[WIP] Hot reloading #930
Conversation
Hi! happy you decided to contribute! I'm wondering if we can split this into:
There is a good chance a simplification can be made for reloading from disk - by just reading a file, and then rendering using a template string (instead of arc/mutex/ etc.). It can make a simpler (yet less clever) code, since we don't much care about perf in debug builds. WDYT? |
Moving this one to 0.14, if you can refactor it into a middleware that only does live-reload that would be perfect! |
Just back from holidays, I'll try to see if I can come up with something simpler this or next week. Think most of the reload logic could probably live in the user side, if we somehow expose methods like |
I have a few notes regarding this PR, live reload functionality, and some related feedback from my app. First (not actually relevant for this PR, but relevant to hot reload) Currently, if I want to register additional functions or filters, I need to implement them in two different places. This is not intuitive and can lead to problem in release (and the test should to catch this problem). If this was done solely for hot reload support, I think we should consider a different approach for its implementation. About this PR:
And regarding pub fn test() -> String {
#[cfg(debug_assertions)]
let res = "#[cfg(debug_assertions)]";
#[cfg(not(debug_assertions))]
let res = "#[cfg(not(debug_assertions))]";
res.to_string()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_debug_assertions() {
assert_eq!(test(), "#[cfg(not(debug_assertions))]");
}
} |
We now reload content from disk. |
Awesome project btw. I kinda started on #920 and wanted your input.
It looks like the
tera
member in theTeraView
struct needs to be made private, to not expose the leaky details about it being either in a Mutex indebug
vs not wrapped inrelease
builds.Perhaps we could add 2 methods,
fn with_tera<'s, A>(&'s mut self, f: impl FnOnce(&'s tera::Tera) -> A ) -> A
fn with_tera_mut<'s, A>(&'s mut self, f: impl FnOnce(&'s mut tera::Tera) -> A ) -> A
Bit also unsure about wiring up the tower-livereload without breaking existing interfaces. I did a roughed up patching within my own code and it works without issues.