Native: implement hot-reloading of stylesheets (#4830)
* Make `tracing` feature of dioxus-native enable `tracing` feature of dioxus-native-dom * Native: implement hotreloading of stylesheet assets * Add asset support for native-headless-in-bevy example Signed-off-by: Nico Burns <nico@nicoburns.com> * Remove println statements Signed-off-by: Nico Burns <nico@nicoburns.com> --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
1 parent
c55a29e930
commit
2bbfccfd04
7 files changed
+227
-6
No files matched your search
@@ -17,7 +17,7 @@ svg = ["blitz-dom/svg", "blitz-paint/svg"]
|
||||
net = ["dep:tokio", "dep:blitz-net"]
|
||||
html = ["dep:blitz-html"]
|
||||
accessibility = ["blitz-shell/accessibility", "blitz-dom/accessibility"]
|
||||
tracing = ["dep:tracing", "blitz-shell/tracing", "blitz-dom/tracing"]
|
||||
tracing = ["dep:tracing", "dioxus-native-dom/tracing", "blitz-shell/tracing", "blitz-dom/tracing"]
|
||||
hot-reload = ["dep:dioxus-cli-config", "dep:dioxus-devtools"]
|
||||
system-fonts = ["blitz-dom/system_fonts"]
|
||||
autofocus = []
|
||||
|
||||
@@ -70,7 +70,17 @@ impl DioxusNativeApplication {
|
||||
dioxus_devtools::DevserverMsg::HotReload(hotreload_message) => {
|
||||
for window in self.inner.windows.values_mut() {
|
||||
let doc = window.downcast_doc_mut::<DioxusDocument>();
|
||||
|
||||
// Apply changes to vdom
|
||||
dioxus_devtools::apply_changes(&doc.vdom, hotreload_message);
|
||||
|
||||
// Reload changed assets
|
||||
for asset_path in &hotreload_message.assets {
|
||||
if let Some(url) = asset_path.to_str() {
|
||||
doc.reload_resource_by_href(url);
|
||||
}
|
||||
}
|
||||
|
||||
window.poll();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user