pub struct UseWebSocketOptions<Rx, E, D>where
Rx: ?Sized,{ /* private fields */ }
Expand description
Options for use_websocket_with_options
.
Implementations§
Source§impl<Rx, E, D> UseWebSocketOptions<Rx, E, D>where
Rx: ?Sized,
impl<Rx, E, D> UseWebSocketOptions<Rx, E, D>where
Rx: ?Sized,
Sourcepub fn on_message_raw(self, value: impl Fn(&str) + 'static) -> Self
pub fn on_message_raw(self, value: impl Fn(&str) + 'static) -> Self
WebSocket
message callback for text.
Sourcepub fn on_message_raw_bytes(self, value: Rc<dyn Fn(&[u8])>) -> Self
pub fn on_message_raw_bytes(self, value: Rc<dyn Fn(&[u8])>) -> Self
WebSocket
message callback for binary.
Sourcepub fn on_close(self, value: impl Fn(CloseEvent) + 'static) -> Self
pub fn on_close(self, value: impl Fn(CloseEvent) + 'static) -> Self
WebSocket
close callback.
Sourcepub fn reconnect_limit(self, value: ReconnectLimit) -> Self
pub fn reconnect_limit(self, value: ReconnectLimit) -> Self
Retry times. Defaults to ReconnectLimit::Limited(3)
. Use ReconnectLimit::Infinite
for
infinite retries.
Sourcepub fn reconnect_interval(self, value: u64) -> Self
pub fn reconnect_interval(self, value: u64) -> Self
Retry interval in ms. Defaults to 3000.
Sourcepub fn immediate(self, value: bool) -> Self
pub fn immediate(self, value: bool) -> Self
If true
the WebSocket
connection will immediately be opened when calling this function.
If false
you have to manually call the open
function.
Defaults to true
.
Sourcepub fn protocols(
self,
value: impl Into<MaybeSignal<Option<Vec<String>>>>,
) -> Self
pub fn protocols( self, value: impl Into<MaybeSignal<Option<Vec<String>>>>, ) -> Self
Sub protocols. See MDN Docs.
Can be set as a signal to support protocols only available after the initial render.
Note that protocols are only updated on the next websocket open() call, not whenever the signal is updated.
Therefore “lazy” protocols should use the immediate(false)
option and manually call open()
.
Source§impl<Rx: ?Sized, E, D> UseWebSocketOptions<Rx, E, D>
impl<Rx: ?Sized, E, D> UseWebSocketOptions<Rx, E, D>
Sourcepub fn on_error<F>(self, handler: F) -> Selfwhere
F: Fn(UseWebSocketError<E, D>) + 'static,
pub fn on_error<F>(self, handler: F) -> Selfwhere
F: Fn(UseWebSocketError<E, D>) + 'static,
WebSocket
error callback.
Sourcepub fn on_message<F>(self, handler: F) -> Self
pub fn on_message<F>(self, handler: F) -> Self
WebSocket
message callback for typed message decoded by codec.
Trait Implementations§
Auto Trait Implementations§
impl<Rx, E, D> Freeze for UseWebSocketOptions<Rx, E, D>where
Rx: ?Sized,
impl<Rx, E, D> !RefUnwindSafe for UseWebSocketOptions<Rx, E, D>
impl<Rx, E, D> !Send for UseWebSocketOptions<Rx, E, D>
impl<Rx, E, D> !Sync for UseWebSocketOptions<Rx, E, D>
impl<Rx, E, D> Unpin for UseWebSocketOptions<Rx, E, D>where
Rx: ?Sized,
impl<Rx, E, D> !UnwindSafe for UseWebSocketOptions<Rx, E, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more