webui/macros/
sync.rs

1/// Macro for running a method after a timeout
2#[macro_export]
3macro_rules! set_timeout {
4    ( $t:expr, $x:expr ) => {
5        let f: Box<dyn FnMut()> = Box::new(move || {
6            $x;
7        });
8        let callback = Closure::wrap(f);
9        _ = set_timeout(callback.as_ref().unchecked_ref(), $t);
10        callback.forget();
11    };
12}
13
14/// Macro for spawning an async process
15#[macro_export]
16macro_rules! spawn_async {
17    ( $x:expr ) => {
18        wasm_bindgen_futures::spawn_local(async move { { $x } });
19    };
20}