mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 19:22:44 +08:00
Add AsyncHandler for wrapping task spawning
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
use std::future::Future;
|
||||
use tauri::{async_runtime, async_runtime::JoinHandle};
|
||||
|
||||
pub struct AsyncHandler;
|
||||
|
||||
impl AsyncHandler {
|
||||
pub fn spawn<F, Fut>(f: F) -> JoinHandle<()>
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: Future<Output = ()> + Send + 'static,
|
||||
{
|
||||
async_runtime::spawn(f())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user