fix hot reload after wasm conditional compilation

This commit is contained in:
me 2025-12-25 01:27:27 +02:00
parent 6dea19e55b
commit fb86131917

View file

@ -24,7 +24,7 @@ async fn main() {
}
rand::srand(macroquad::miniquad::date::now() as _);
let reader = hotwatch();
let (_hot, reader) = hotwatch();
match read_file() {
Err(err) => println!("Error: {err:#?}"),
@ -70,7 +70,7 @@ fn read_file() -> std::io::Result<String> {
}
#[cfg(not(target_arch = "wasm32"))]
fn hotwatch() -> Arc<RwLock<Option<ayin::ast::Program>>> {
fn hotwatch() -> (hotwatch::Hotwatch, Arc<RwLock<Option<ayin::ast::Program>>>) {
let writer = Arc::new(RwLock::new(None));
let reader = writer.clone();
let args: Vec<String> = std::env::args().collect();
@ -93,11 +93,11 @@ fn hotwatch() -> Arc<RwLock<Option<ayin::ast::Program>>> {
}
})
.expect("failed to watch file!");
reader
(hotwatch, reader)
}
#[cfg(target_arch = "wasm32")]
fn hotwatch() -> Arc<RwLock<Option<ayin::ast::Program>>> {
fn hotwatch() -> ((), Arc<RwLock<Option<ayin::ast::Program>>>) {
let writer = Arc::new(RwLock::new(None));
let reader = writer.clone();
reader
((), reader)
}