diff --git a/src/websocket/use_websocket.rs b/src/websocket/use_websocket.rs index 14b002b..6b77e99 100644 --- a/src/websocket/use_websocket.rs +++ b/src/websocket/use_websocket.rs @@ -26,48 +26,50 @@ use crate::utils::CloneableFnWithArg; /// # #[component] /// # fn Demo(cx: Scope) -> impl IntoView { /// let UseWebsocketReturn { -/// ready_state, -/// message, -/// message_bytes, -/// send, -/// send_bytes, -/// open, -/// close, -/// .. -/// } = use_websocket(cx, "wss://echo.websocket.events/".to_string()); +/// ready_state, +/// message, +/// message_bytes, +/// send, +/// send_bytes, +/// open, +/// close, +/// .. +/// } = use_websocket(cx, "wss://echo.websocket.events/".to_string()); /// /// let send_message = move |_| { -/// let m = "Hello, world!".to_string(); -/// send(m.clone()); +/// let m = "Hello, world!".to_string(); +/// send(m.clone()); /// }; /// /// let send_byte_message = move |_| { -/// let m = b"Hello, world!\r\n".to_vec(); -/// send_bytes(m.clone()); +/// let m = b"Hello, world!\r\n".to_vec(); +/// send_bytes(m.clone()); /// }; /// -/// let status = move || ready_state().to_string(); +/// let status = move || ready_state.get().to_string(); /// /// let connected = move || ready_state.get() == UseWebSocketReadyState::Open; /// /// let open_connection = move |_| { -/// open(); +/// open(); /// }; /// /// let close_connection = move |_| { -/// close(); +/// close(); /// }; /// /// view! { cx, -///
-///

"status: " {status}

-/// button on:click=send_message disabled=move || !connected()>"Send" -/// -/// -/// -///

"Receive message: " {format! {"{:?}", message}}

-///

"Receive byte message: " {format! {"{:?}", message_bytes}}

-///
+///
+///

"status: " {status}

+/// +/// +/// +/// +/// +/// +///

"Receive message: " {format! {"{:?}", message}}

+///

"Receive byte message: " {format! {"{:?}", message_bytes}}

+///
/// } /// # } /// ``` @@ -371,15 +373,15 @@ impl fmt::Display for UseWebSocketReadyState { #[derive(DefaultBuilder)] pub struct UseWebSocketOptions { /// `WebSocket` connect callback. - on_open: Box + 'static>, + on_open: Box>, /// `WebSocket` message callback for text. - on_message: Box + 'static>, + on_message: Box>, /// `WebSocket` message callback for binary. - on_message_bytes: Box> + 'static>, + on_message_bytes: Box>>, /// `WebSocket` error callback. - on_error: Box + 'static>, + on_error: Box>, /// `WebSocket` close callback. - on_close: Box + 'static>, + on_close: Box>, /// Retry times. reconnect_limit: Option, /// Retry interval(ms).