2 releases
0.1.1 | Sep 9, 2023 |
---|---|
0.1.0 | Sep 9, 2023 |
#23 in #hot-reload
8KB
147 lines
Hot-Sauce
It's wrapper to allow you dynamic update some data like config.
You can sync the data to the newest version or get cached data of last sync, or publish a data.
cargo add hot-sauce
Usage
pub fn main() {
use std::thread;
let source = HotSource::<str>::new("hello world");
let mut message = source.get();
thread::spawn(move || {
let mut version = 0;
loop {
thread::sleep(std::time::Duration::from_millis(100));
version += 1;
message.update(format!("hello world {}", version));
}
});
let mut message = source.get();
for _ in 0..10 {
thread::sleep(std::time::Duration::from_millis(50));
message.sync();
println!("{}", &**message);
}
}
Dependencies
~165KB