mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 00:59:22 -05:00
Allow for lazy protocols with use_websocket
This commit is contained in:
parent
04bcb6b319
commit
00ced832b2
1 changed files with 15 additions and 12 deletions
|
@ -344,6 +344,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let web_socket = {
|
let web_socket = {
|
||||||
|
protocols.with_untracked(|protocols| {
|
||||||
protocols.as_ref().map_or_else(
|
protocols.as_ref().map_or_else(
|
||||||
|| WebSocket::new(&url).unwrap_throw(),
|
|| WebSocket::new(&url).unwrap_throw(),
|
||||||
|protocols| {
|
|protocols| {
|
||||||
|
@ -355,6 +356,7 @@ where
|
||||||
.unwrap_throw()
|
.unwrap_throw()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
})
|
||||||
};
|
};
|
||||||
web_socket.set_binary_type(BinaryType::Arraybuffer);
|
web_socket.set_binary_type(BinaryType::Arraybuffer);
|
||||||
set_ready_state.set(ConnectionReadyState::Connecting);
|
set_ready_state.set(ConnectionReadyState::Connecting);
|
||||||
|
@ -650,7 +652,8 @@ where
|
||||||
/// Defaults to `true`.
|
/// Defaults to `true`.
|
||||||
immediate: bool,
|
immediate: bool,
|
||||||
/// Sub protocols. See [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket#protocols).
|
/// Sub protocols. See [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket#protocols).
|
||||||
protocols: Option<Vec<String>>,
|
#[builder(into)]
|
||||||
|
protocols: MaybeSignal<Option<Vec<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Rx: ?Sized, E, D> UseWebSocketOptions<Rx, E, D> {
|
impl<Rx: ?Sized, E, D> UseWebSocketOptions<Rx, E, D> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue