From 2729929928f1f31101e0e23ea5c4b6ebc916d68b Mon Sep 17 00:00:00 2001 From: Jet Li Date: Sun, 26 May 2024 10:57:56 +0800 Subject: [PATCH 1/2] fix use_websocket reconnect_limit defaults to for infinite retries, fix #41 --- crates/yew-hooks/src/hooks/use_websocket.rs | 4 ++-- crates/yew-hooks/src/web_sys_ext.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/yew-hooks/src/hooks/use_websocket.rs b/crates/yew-hooks/src/hooks/use_websocket.rs index d39a63f..ecf74fd 100644 --- a/crates/yew-hooks/src/hooks/use_websocket.rs +++ b/crates/yew-hooks/src/hooks/use_websocket.rs @@ -33,7 +33,7 @@ pub struct UseWebSocketOptions { /// `WebSocket` close callback. pub onclose: Option>, - /// Retry times. Defaults to 3, use `u32::MAX` for infinite retries. + /// Retry times. Defaults to `u32::MAX` for infinite retries. pub reconnect_limit: Option, /// Retry interval(ms). Defaults to 3000. pub reconnect_interval: Option, @@ -235,7 +235,7 @@ pub fn use_websocket_with_options(url: String, options: UseWebSocketOptions) -> let onmessage_bytes_ref = use_mut_latest(options.onmessage_bytes); let onerror_ref = use_mut_latest(options.onerror); let onclose_ref = use_mut_latest(options.onclose); - let reconnect_limit = options.reconnect_limit.unwrap_or(3); + let reconnect_limit = options.reconnect_limit.unwrap_or(u32::MAX); let reconnect_interval = options.reconnect_interval.unwrap_or(3 * 1000); let manual = options.manual.unwrap_or(false); let protocols = options.protocols; diff --git a/crates/yew-hooks/src/web_sys_ext.rs b/crates/yew-hooks/src/web_sys_ext.rs index f29fa64..237613c 100644 --- a/crates/yew-hooks/src/web_sys_ext.rs +++ b/crates/yew-hooks/src/web_sys_ext.rs @@ -3,6 +3,7 @@ //! which is inconvenient, so copy the binding code here for now. #![allow(unused_imports)] #![allow(clippy::unused_unit)] +#![allow(clippy::empty_docs)] use wasm_bindgen::{self, prelude::*}; use web_sys::{DataTransfer, DomRectReadOnly, Element, Event, EventTarget}; From fff9364722dd44c0615b589d8dad2dd4f95e976c Mon Sep 17 00:00:00 2001 From: Jet Li Date: Sun, 26 May 2024 11:04:53 +0800 Subject: [PATCH 2/2] release 0.3.2 --- crates/yew-hooks/Cargo.toml | 4 ++-- examples/yew-app/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/yew-hooks/Cargo.toml b/crates/yew-hooks/Cargo.toml index cdde7fb..bd40da2 100644 --- a/crates/yew-hooks/Cargo.toml +++ b/crates/yew-hooks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yew-hooks" -version = "0.3.1" +version = "0.3.2" edition = "2021" authors = ["Jet Li "] categories = ["gui", "wasm", "web-programming"] @@ -17,7 +17,7 @@ documentation = "https://docs.rs/yew-hooks/" [dependencies] log = "0.4" yew = { version = "0.21.0", features = ["csr"] } -gloo = "0.10" +gloo = "0.11" wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" serde = "1" diff --git a/examples/yew-app/Cargo.toml b/examples/yew-app/Cargo.toml index 5eaa2c0..cdfd351 100644 --- a/examples/yew-app/Cargo.toml +++ b/examples/yew-app/Cargo.toml @@ -13,10 +13,10 @@ version = "0.1.0" [dependencies] log = "0.4" -gloo = "0.10" +gloo = "0.11" js-sys = "0.3" serde = "1" -reqwest = { version = "0.11.7", features = ["json"] } +reqwest = { version = "0.12.4", features = ["json"] } yew = { version = "0.21.0", features = ["csr"] } yew-router = { version = "0.18.0" } yew-hooks = { path = "../../crates/yew-hooks" }