websocket cleanup

This commit is contained in:
Maccesch 2023-07-13 11:25:32 +01:00
parent ddbc1c1db5
commit a0004a4559

View file

@ -46,7 +46,7 @@ use crate::utils::CloneableFnWithArg;
/// 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;
///
@ -61,10 +61,12 @@ use crate::utils::CloneableFnWithArg;
/// view! { cx,
/// <div>
/// <p>"status: " {status}</p>
/// button on:click=send_message disabled=move || !connected()>"Send"</button>
///
/// <button on:click=send_message disabled=move || !connected()>"Send"</button>
/// <button on:click=send_byte_message disabled=move || !connected()>"Send bytes"</button>
/// <button on:click=open_connection disabled=connected>"Open"</button>
/// <button on:click=close_connection disabled=move || !connected()>"Close"</button>
///
/// <p>"Receive message: " {format! {"{:?}", message}}</p>
/// <p>"Receive byte message: " {format! {"{:?}", message_bytes}}</p>
/// </div>
@ -371,15 +373,15 @@ impl fmt::Display for UseWebSocketReadyState {
#[derive(DefaultBuilder)]
pub struct UseWebSocketOptions {
/// `WebSocket` connect callback.
on_open: Box<dyn CloneableFnWithArg<Event> + 'static>,
on_open: Box<dyn CloneableFnWithArg<Event>>,
/// `WebSocket` message callback for text.
on_message: Box<dyn CloneableFnWithArg<String> + 'static>,
on_message: Box<dyn CloneableFnWithArg<String>>,
/// `WebSocket` message callback for binary.
on_message_bytes: Box<dyn CloneableFnWithArg<Vec<u8>> + 'static>,
on_message_bytes: Box<dyn CloneableFnWithArg<Vec<u8>>>,
/// `WebSocket` error callback.
on_error: Box<dyn CloneableFnWithArg<Event> + 'static>,
on_error: Box<dyn CloneableFnWithArg<Event>>,
/// `WebSocket` close callback.
on_close: Box<dyn CloneableFnWithArg<CloseEvent> + 'static>,
on_close: Box<dyn CloneableFnWithArg<CloseEvent>>,
/// Retry times.
reconnect_limit: Option<u64>,
/// Retry interval(ms).