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

pull/338/head
Fabian-Lars 2 years ago committed by GitHub
parent 46f4a949c9
commit 8de442113f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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