mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-22 16:49:22 -05:00
Merge pull request #164 from zakstucke/main
This commit is contained in:
commit
38b988d453
2 changed files with 21 additions and 13 deletions
|
@ -336,7 +336,7 @@ use_web_notification = [
|
|||
"web-sys/NotificationDirection",
|
||||
"web-sys/VisibilityState"
|
||||
]
|
||||
use_websocket = ["dep:codee"]
|
||||
use_websocket = ["dep:web-sys", "dep:codee"]
|
||||
use_window = ["use_document", "dep:web-sys", "web-sys/Navigator", "web-sys/MediaQueryList"]
|
||||
use_window_focus = ["use_event_listener"]
|
||||
use_window_scroll = ["use_event_listener", "use_window"]
|
||||
|
|
|
@ -344,6 +344,7 @@ where
|
|||
}
|
||||
|
||||
let web_socket = {
|
||||
protocols.with_untracked(|protocols| {
|
||||
protocols.as_ref().map_or_else(
|
||||
|| WebSocket::new(&url).unwrap_throw(),
|
||||
|protocols| {
|
||||
|
@ -355,6 +356,7 @@ where
|
|||
.unwrap_throw()
|
||||
},
|
||||
)
|
||||
})
|
||||
};
|
||||
web_socket.set_binary_type(BinaryType::Arraybuffer);
|
||||
set_ready_state.set(ConnectionReadyState::Connecting);
|
||||
|
@ -650,7 +652,13 @@ where
|
|||
/// Defaults to `true`.
|
||||
immediate: bool,
|
||||
/// Sub protocols. See [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket#protocols).
|
||||
protocols: Option<Vec<String>>,
|
||||
///
|
||||
/// 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()`.
|
||||
#[builder(into)]
|
||||
protocols: MaybeSignal<Option<Vec<String>>>,
|
||||
}
|
||||
|
||||
impl<Rx: ?Sized, E, D> UseWebSocketOptions<Rx, E, D> {
|
||||
|
|
Loading…
Add table
Reference in a new issue