fix(ws): Don't block main thread while connecting

pull/337/head
FabianLars 2 years ago
parent 46f4a949c9
commit 32d1db2baa
No known key found for this signature in database
GPG Key ID: 3B12BC1DEBF61125

@ -79,15 +79,14 @@ enum WebSocketMessage {
}
#[tauri::command]
fn connect<R: Runtime>(
async fn connect<R: Runtime>(
window: Window<R>,
url: String,
callback_function: CallbackFn,
config: Option<ConnectionConfig>,
) -> Result<Id> {
let id = rand::random();
let (ws_stream, _) =
tauri::async_runtime::block_on(connect_async_with_config(url, config.map(Into::into)))?;
let (ws_stream, _) = connect_async_with_config(url, config.map(Into::into)).await?;
tauri::async_runtime::spawn(async move {
let (write, read) = ws_stream.split();

Loading…
Cancel
Save