mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-03-13 01:09:48 -04:00
fixed websocket test and removed all warnings from tests
This commit is contained in:
parent
b6a5d36df1
commit
e00f461ea7
13 changed files with 29 additions and 29 deletions
|
@ -9,7 +9,7 @@ function [`use_element_size`](elements/use_element_size.md) returns the width an
|
||||||
#
|
#
|
||||||
# #[component]
|
# #[component]
|
||||||
# pub fn Component() -> impl IntoView {
|
# pub fn Component() -> impl IntoView {
|
||||||
let el = create_node_ref::<Div>();
|
let el = NodeRef::<Div>::new();
|
||||||
|
|
||||||
let UseElementSizeReturn { width, height } = use_element_size(el);
|
let UseElementSizeReturn { width, height } = use_element_size(el);
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ use_resize_observer([window().body(), document().query_selector("div > p.some-cl
|
||||||
use_resize_observer(vec!["div > p.some-class", "p.some-class"]);
|
use_resize_observer(vec!["div > p.some-class", "p.some-class"]);
|
||||||
|
|
||||||
// Slice of NodeRef
|
// Slice of NodeRef
|
||||||
let node_ref1 = create_node_ref::<Div>();
|
let node_ref1 = NodeRef::<Div>::new();
|
||||||
let node_ref2 = create_node_ref::<Div>();
|
let node_ref2 = NodeRef::<Div>::new();
|
||||||
use_resize_observer(vec![node_ref1, node_ref2].as_slice());
|
use_resize_observer(vec![node_ref1, node_ref2].as_slice());
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let drop_zone_el = create_node_ref::<Div>();
|
/// let drop_zone_el = NodeRef::<Div>::new();
|
||||||
///
|
///
|
||||||
/// let on_drop = |event| {
|
/// let on_drop = |event| {
|
||||||
/// // called when files are dropped on zone
|
/// // called when files are dropped on zone
|
||||||
|
|
|
@ -19,7 +19,7 @@ use leptos::prelude::*;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let el = create_node_ref::<Div>();
|
/// let el = NodeRef::<Div>::new();
|
||||||
/// let UseElementBoundingReturn {
|
/// let UseElementBoundingReturn {
|
||||||
/// x, y, top,right,bottom,left, width, height, ..
|
/// x, y, top,right,bottom,left, width, height, ..
|
||||||
/// } = use_element_bounding(el);
|
/// } = use_element_bounding(el);
|
||||||
|
|
|
@ -26,7 +26,7 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let el = create_node_ref::<Button>();
|
/// let el = NodeRef::<Button>::new();
|
||||||
/// let is_hovered = use_element_hover(el);
|
/// let is_hovered = use_element_hover(el);
|
||||||
///
|
///
|
||||||
/// view! {
|
/// view! {
|
||||||
|
|
|
@ -23,7 +23,7 @@ use leptos::prelude::wrappers::read::Signal;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let el = create_node_ref::<Div>();
|
/// let el = NodeRef::<Div>::new();
|
||||||
///
|
///
|
||||||
/// let is_visible = use_element_visibility(el);
|
/// let is_visible = use_element_visibility(el);
|
||||||
///
|
///
|
||||||
|
|
|
@ -44,7 +44,7 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let element = create_node_ref();
|
/// let element = NodeRef::new();
|
||||||
///
|
///
|
||||||
/// use_event_listener(element, click, |evt| {
|
/// use_event_listener(element, click, |evt| {
|
||||||
/// log!("click from element {:?}", event_target::<web_sys::HtmlDivElement>(&evt));
|
/// log!("click from element {:?}", event_target::<web_sys::HtmlDivElement>(&evt));
|
||||||
|
|
|
@ -28,7 +28,7 @@ use wasm_bindgen::JsCast;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let el = create_node_ref::<Div>();
|
/// let el = NodeRef::<Div>::new();
|
||||||
///
|
///
|
||||||
/// let (data, set_data) = signal(vec![1, 2, 3, 4, 5, 6]);
|
/// let (data, set_data) = signal(vec![1, 2, 3, 4, 5, 6]);
|
||||||
///
|
///
|
||||||
|
|
|
@ -30,7 +30,7 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let el = create_node_ref::<Div>();
|
/// let el = NodeRef::<Div>::new();
|
||||||
/// let (is_visible, set_visible) = signal(false);
|
/// let (is_visible, set_visible) = signal(false);
|
||||||
///
|
///
|
||||||
/// use_intersection_observer(
|
/// use_intersection_observer(
|
||||||
|
|
|
@ -72,7 +72,7 @@ use wasm_bindgen::{JsCast, JsValue};
|
||||||
///
|
///
|
||||||
/// #[component]
|
/// #[component]
|
||||||
/// fn Demo() -> impl IntoView {
|
/// fn Demo() -> impl IntoView {
|
||||||
/// let element = create_node_ref::<Div>();
|
/// let element = NodeRef::<Div>::new();
|
||||||
///
|
///
|
||||||
/// let UseMouseReturn {
|
/// let UseMouseReturn {
|
||||||
/// x, y, source_type, ..
|
/// x, y, source_type, ..
|
||||||
|
|
|
@ -24,7 +24,7 @@ use std::marker::PhantomData;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let target = create_node_ref::<Div>();
|
/// let target = NodeRef::<Div>::new();
|
||||||
/// let UseMouseInElementReturn { x, y, is_outside, .. } = use_mouse_in_element(target);
|
/// let UseMouseInElementReturn { x, y, is_outside, .. } = use_mouse_in_element(target);
|
||||||
///
|
///
|
||||||
/// view! {
|
/// view! {
|
||||||
|
|
|
@ -28,7 +28,7 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let el = create_node_ref::<Pre>();
|
/// let el = NodeRef::<Pre>::new();
|
||||||
/// let (text, set_text) = signal("".to_string());
|
/// let (text, set_text) = signal("".to_string());
|
||||||
///
|
///
|
||||||
/// use_mutation_observer_with_options(
|
/// use_mutation_observer_with_options(
|
||||||
|
|
|
@ -38,7 +38,7 @@ const ARRIVED_STATE_THRESHOLD_PIXELS: f64 = 1.0;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let element = create_node_ref::<Div>();
|
/// let element = NodeRef::<Div>::new();
|
||||||
///
|
///
|
||||||
/// let UseScrollReturn {
|
/// let UseScrollReturn {
|
||||||
/// x, y, set_x, set_y, is_scrolling, arrived_state, directions, ..
|
/// x, y, set_x, set_y, is_scrolling, arrived_state, directions, ..
|
||||||
|
@ -63,7 +63,7 @@ const ARRIVED_STATE_THRESHOLD_PIXELS: f64 = 1.0;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// # let element = create_node_ref::<Div>();
|
/// # let element = NodeRef::<Div>::new();
|
||||||
/// #
|
/// #
|
||||||
/// let UseScrollReturn {
|
/// let UseScrollReturn {
|
||||||
/// x,
|
/// x,
|
||||||
|
@ -101,7 +101,7 @@ const ARRIVED_STATE_THRESHOLD_PIXELS: f64 = 1.0;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let element = create_node_ref::<Div>();
|
/// let element = NodeRef::<Div>::new();
|
||||||
///
|
///
|
||||||
/// let UseScrollReturn {
|
/// let UseScrollReturn {
|
||||||
/// x, y, set_x, set_y, ..
|
/// x, y, set_x, set_y, ..
|
||||||
|
@ -129,7 +129,7 @@ const ARRIVED_STATE_THRESHOLD_PIXELS: f64 = 1.0;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// # let element = create_node_ref::<Div>();
|
/// # let element = NodeRef::<Div>::new();
|
||||||
/// #
|
/// #
|
||||||
/// let UseScrollReturn {
|
/// let UseScrollReturn {
|
||||||
/// x, y, set_x, set_y, ..
|
/// x, y, set_x, set_y, ..
|
||||||
|
@ -153,7 +153,7 @@ const ARRIVED_STATE_THRESHOLD_PIXELS: f64 = 1.0;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// # let element = create_node_ref::<Div>();
|
/// # let element = NodeRef::<Div>::new();
|
||||||
/// #
|
/// #
|
||||||
/// let (smooth, set_smooth) = signal(false);
|
/// let (smooth, set_smooth) = signal(false);
|
||||||
///
|
///
|
||||||
|
|
|
@ -168,11 +168,11 @@ use web_sys::{BinaryType, CloseEvent, Event, MessageEvent, WebSocket};
|
||||||
/// # #[derive(Clone)]
|
/// # #[derive(Clone)]
|
||||||
/// # pub struct WebsocketContext {
|
/// # pub struct WebsocketContext {
|
||||||
/// # pub message: Signal<Option<String>>,
|
/// # pub message: Signal<Option<String>>,
|
||||||
/// # send: Arc<dyn Fn(&String)>,
|
/// # send: Arc<dyn Fn(&String) + Send + Sync>,
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
/// #
|
||||||
/// # impl WebsocketContext {
|
/// # impl WebsocketContext {
|
||||||
/// # pub fn new(message: Signal<Option<String>>, send: Arc<dyn Fn(&String)>) -> Self {
|
/// # pub fn new(message: Signal<Option<String>>, send: Arc<dyn Fn(&String) + Send + Sync>) -> Self {
|
||||||
/// # Self {
|
/// # Self {
|
||||||
/// # message,
|
/// # message,
|
||||||
/// # send,
|
/// # send,
|
||||||
|
@ -231,9 +231,9 @@ pub fn use_websocket<Tx, Rx, C>(
|
||||||
) -> UseWebSocketReturn<
|
) -> UseWebSocketReturn<
|
||||||
Tx,
|
Tx,
|
||||||
Rx,
|
Rx,
|
||||||
impl Fn() + Clone + 'static,
|
impl Fn() + Clone + Send + Sync + 'static,
|
||||||
impl Fn() + Clone + 'static,
|
impl Fn() + Clone + Send + Sync + 'static,
|
||||||
impl Fn(&Tx) + Clone + 'static,
|
impl Fn(&Tx) + Clone + Send + Sync + 'static,
|
||||||
>
|
>
|
||||||
where
|
where
|
||||||
Tx: Send + Sync + 'static,
|
Tx: Send + Sync + 'static,
|
||||||
|
@ -257,9 +257,9 @@ pub fn use_websocket_with_options<Tx, Rx, C>(
|
||||||
) -> UseWebSocketReturn<
|
) -> UseWebSocketReturn<
|
||||||
Tx,
|
Tx,
|
||||||
Rx,
|
Rx,
|
||||||
impl Fn() + Clone + 'static,
|
impl Fn() + Clone + Send + Sync + 'static,
|
||||||
impl Fn() + Clone + 'static,
|
impl Fn() + Clone + Send + Sync + 'static,
|
||||||
impl Fn(&Tx) + Clone + 'static,
|
impl Fn(&Tx) + Clone + Send + Sync + 'static,
|
||||||
>
|
>
|
||||||
where
|
where
|
||||||
Tx: Send + Sync + 'static,
|
Tx: Send + Sync + 'static,
|
||||||
|
@ -700,9 +700,9 @@ pub struct UseWebSocketReturn<Tx, Rx, OpenFn, CloseFn, SendFn>
|
||||||
where
|
where
|
||||||
Tx: Send + Sync + 'static,
|
Tx: Send + Sync + 'static,
|
||||||
Rx: Send + Sync + 'static,
|
Rx: Send + Sync + 'static,
|
||||||
OpenFn: Fn() + Clone + 'static,
|
OpenFn: Fn() + Clone + Send + Sync + 'static,
|
||||||
CloseFn: Fn() + Clone + 'static,
|
CloseFn: Fn() + Clone + Send + Sync + 'static,
|
||||||
SendFn: Fn(&Tx) + Clone + 'static,
|
SendFn: Fn(&Tx) + Clone + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
/// The current state of the `WebSocket` connection.
|
/// The current state of the `WebSocket` connection.
|
||||||
pub ready_state: Signal<ConnectionReadyState>,
|
pub ready_state: Signal<ConnectionReadyState>,
|
||||||
|
|
Loading…
Add table
Reference in a new issue