From 82cfc387aaa16e507039c13ee38788274e4d2535 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Tue, 15 Aug 2023 12:31:25 +0100 Subject: [PATCH 1/8] moved some stored values in use_raf_fn to Cells to avoid potential loss of context errors --- src/use_raf_fn.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/use_raf_fn.rs b/src/use_raf_fn.rs index b5c6755..77bb5fb 100644 --- a/src/use_raf_fn.rs +++ b/src/use_raf_fn.rs @@ -1,7 +1,7 @@ use crate::utils::Pausable; use default_struct_builder::DefaultBuilder; use leptos::*; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; use std::rc::Rc; use wasm_bindgen::closure::Closure; use wasm_bindgen::JsCast; @@ -47,8 +47,7 @@ pub fn use_raf_fn_with_options( ) -> Pausable { let UseRafFnOptions { immediate } = options; - let previous_frame_timestamp = store_value(0.0_f64); - let raf_handle = store_value(None::); + let raf_handle = Rc::new(Cell::new(None::)); let (is_active, set_active) = create_signal(false); @@ -56,11 +55,12 @@ pub fn use_raf_fn_with_options( let request_next_frame = { let loop_ref = Rc::clone(&loop_ref); + let raf_handle = Rc::clone(&raf_handle); move || { let loop_ref = Rc::clone(&loop_ref); - raf_handle.set_value( + raf_handle.set( window() .request_animation_frame( Closure::once_into_js(move |timestamp: f64| { @@ -76,13 +76,14 @@ pub fn use_raf_fn_with_options( let loop_fn = { let request_next_frame = request_next_frame.clone(); + let mut previous_frame_timestamp = Cell::new(0.0_f64); move |timestamp: f64| { if !is_active.get() { return; } - let prev_timestamp = previous_frame_timestamp.get_value(); + let prev_timestamp = previous_frame_timestamp.get(); let delta = if prev_timestamp > 0.0 { timestamp - prev_timestamp } else { @@ -91,7 +92,7 @@ pub fn use_raf_fn_with_options( callback(UseRafFnCallbackArgs { delta, timestamp }); - previous_frame_timestamp.set_value(timestamp); + previous_frame_timestamp.set(timestamp); request_next_frame(); } @@ -109,18 +110,18 @@ pub fn use_raf_fn_with_options( let pause = move || { set_active.set(false); - let handle = raf_handle.get_value(); + let handle = raf_handle.get(); if let Some(handle) = handle { let _ = window().cancel_animation_frame(handle); } - raf_handle.set_value(None); + raf_handle.set(None); }; if immediate { resume(); } - on_cleanup(pause); + on_cleanup(pause.clone()); Pausable { resume, From 717f596e0a6ff6d8820704b25d637f683259bf3a Mon Sep 17 00:00:00 2001 From: Maccesch Date: Tue, 15 Aug 2023 16:59:56 +0100 Subject: [PATCH 2/8] added discord to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 75c44b4..f86c7c8 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ [![Docs](https://docs.rs/leptos-use/badge.svg)](https://docs.rs/leptos-use/) [![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/synphonyte/leptos-use#license) [![Build Status](https://github.com/synphonyte/leptos-use/actions/workflows/ci.yml/badge.svg)](https://github.com/synphonyte/leptos-use/actions/workflows/ci.yml) +[![Discord](https://img.shields.io/discord/1031524867910148188?color=%237289DA&label=discord)](https://discord.com/channels/1031524867910148188/1121154537709895783) ```rust use leptos::*; From 4b306ce4bd000c043c4beb20fe3dae562520acd9 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Tue, 15 Aug 2023 17:00:06 +0100 Subject: [PATCH 3/8] increased version to beta --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6de42f6..da58b11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leptos-use" -version = "0.7.0-alpha" +version = "0.7.0-beta" edition = "2021" authors = ["Marc-Stefan Cassola"] categories = ["gui", "web-programming"] From 036fe98c342032a96fb3cc60fe3de90254b2dcee Mon Sep 17 00:00:00 2001 From: Maccesch Date: Tue, 15 Aug 2023 17:04:32 +0100 Subject: [PATCH 4/8] increased version to beta --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f86c7c8..76027cd 100644 --- a/README.md +++ b/README.md @@ -90,4 +90,4 @@ To scaffold a new function quickly you can run `template/createfn.sh`. It requir |---------------|---------------------------| | <= 0.3 | 0.3 | | 0.4, 0.5, 0.6 | 0.4 | -| main | 0.5.0-alpha | +| main | 0.5.0-alpha/beta | From cd34a9f3e6ee64f231b5a503448629e102b3bf25 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Wed, 16 Aug 2023 16:23:29 +0100 Subject: [PATCH 5/8] made use_scroll usable on the server --- CHANGELOG.md | 11 +- src/use_raf_fn.rs | 2 +- src/use_scroll.rs | 403 +++++++++++++++++++++++----------------------- 3 files changed, 212 insertions(+), 204 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 839143b..e89e53c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `signal_debounced` - `signal_throttled` -### Braking Changes 🛠 +### Breaking Changes 🛠 - Leptos version is now 0.5 - No `cx: Scope` params are supported/needed anymore because of the changes in Leptos. @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Callbacks in options don't require to be cloneable anymore - Callback in `use_raf_fn` doesn't require to be cloneable anymore +- `use_scroll` is now callable on the server ### Fixes 🍕 @@ -69,7 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `is_some` - `use_raf_fn` -### Braking Changes 🛠 +### Breaking Changes 🛠 - The following functions now accept a `MaybeRwSignal` as their initial/default value which means you can use a synchronized `RwSignal` in those places. @@ -112,7 +113,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.4.0] - 2023-07-03 -### Braking Changes 🛠 +### Breaking Changes 🛠 - Required `leptos` version is now 0.4 - Following the changes in `leptos` there is no longer a `stable` crate feature required in order to use this library @@ -149,7 +150,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.3.0] - 2023-06-13 -### Braking Changes 🛠 +### Breaking Changes 🛠 - `use_event_listener` no longer returns a `Box` but a `impl Fn() + Clone` @@ -179,7 +180,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.2.0] - 2023-06-11 -### Braking Changes +### Breaking Changes - `watch` doesn't accept `immediate` as a direct argument anymore. This is only provided by the option variant. - `watch` has now variant `watch_with_options` which allows for debouncing and throttling. diff --git a/src/use_raf_fn.rs b/src/use_raf_fn.rs index 77bb5fb..c44a00a 100644 --- a/src/use_raf_fn.rs +++ b/src/use_raf_fn.rs @@ -76,7 +76,7 @@ pub fn use_raf_fn_with_options( let loop_fn = { let request_next_frame = request_next_frame.clone(); - let mut previous_frame_timestamp = Cell::new(0.0_f64); + let previous_frame_timestamp = Cell::new(0.0_f64); move |timestamp: f64| { if !is_active.get() { diff --git a/src/use_scroll.rs b/src/use_scroll.rs index c495051..e7e7d2d 100644 --- a/src/use_scroll.rs +++ b/src/use_scroll.rs @@ -1,6 +1,7 @@ use crate::core::ElementMaybeSignal; use crate::use_event_listener::use_event_listener_with_options; use crate::{use_debounce_fn_with_arg, use_throttle_fn_with_arg_and_options, ThrottleOptions}; +use cfg_if::cfg_if; use default_struct_builder::DefaultBuilder; use leptos::ev::EventDescriptor; use leptos::*; @@ -161,7 +162,7 @@ use wasm_bindgen::JsCast; /// /// ## Server-Side Rendering /// -/// Please refer to ["Functions with Target Elements"](https://leptos-use.rs/server_side_rendering.html#functions-with-target-elements) +/// On the server this returns signals that don't change and setters that are noops. pub fn use_scroll(element: El) -> UseScrollReturn where El: Clone, @@ -182,40 +183,6 @@ where let (internal_x, set_internal_x) = create_signal(0.0); let (internal_y, set_internal_y) = create_signal(0.0); - let signal = (element).into(); - let behavior = options.behavior; - - let scroll_to = { - let signal = signal.clone(); - - move |x: Option, y: Option| { - let element = signal.get_untracked(); - - if let Some(element) = element { - let element = element.into(); - - let mut scroll_options = web_sys::ScrollToOptions::new(); - scroll_options.behavior(behavior.get_untracked().into()); - - if let Some(x) = x { - scroll_options.left(x); - } - if let Some(y) = y { - scroll_options.top(y); - } - - element.scroll_to_with_scroll_to_options(&scroll_options); - } - } - }; - - let set_x = { - let scroll_to = scroll_to.clone(); - Box::new(move |x| scroll_to(Some(x), None)) - }; - - let set_y = Box::new(move |y| scroll_to(None, Some(y))); - let (is_scrolling, set_is_scrolling) = create_signal(false); let arrived_state = create_rw_signal(Directions { @@ -231,182 +198,222 @@ where bottom: false, }); - let on_scroll_end = { - let on_stop = Rc::clone(&options.on_stop); + cfg_if! { if #[cfg(feature = "ssr")] { + let set_x = Box::new(|_| {}); + let set_y = Box::new(|_| {}); + let measure = Box::new(|| {}); + } else { + let signal = element.into(); + let behavior = options.behavior; - move |e| { - if !is_scrolling.get_untracked() { - return; - } + let scroll_to = { + let signal = signal.clone(); - set_is_scrolling.set(false); - directions.update(|directions| { - directions.left = false; - directions.right = false; - directions.top = false; - directions.bottom = false; - on_stop.clone()(e); - }); - } - }; + move |x: Option, y: Option| { + let element = signal.get_untracked(); - let throttle = options.throttle; + if let Some(element) = element { + let element = element.into(); - let on_scroll_end_debounced = - use_debounce_fn_with_arg(on_scroll_end.clone(), throttle + options.idle); + let mut scroll_options = web_sys::ScrollToOptions::new(); + scroll_options.behavior(behavior.get_untracked().into()); - let offset = options.offset; + if let Some(x) = x { + scroll_options.left(x); + } + if let Some(y) = y { + scroll_options.top(y); + } - let set_arrived_state = move |target: web_sys::Element| { - let style = window() - .get_computed_style(&target) - .expect("failed to get computed style"); - - if let Some(style) = style { - let display = style - .get_property_value("display") - .expect("failed to get display"); - let flex_direction = style - .get_property_value("flex-direction") - .expect("failed to get flex-direction"); - - let scroll_left = target.scroll_left() as f64; - let scroll_left_abs = scroll_left.abs(); - - directions.update(|directions| { - directions.left = scroll_left < internal_x.get_untracked(); - directions.right = scroll_left > internal_x.get_untracked(); - }); - - let left = scroll_left_abs <= offset.left; - let right = scroll_left_abs + target.client_width() as f64 - >= target.scroll_width() as f64 - offset.right - ARRIVED_STATE_THRESHOLD_PIXELS; - - arrived_state.update(|arrived_state| { - if display == "flex" && flex_direction == "row-reverse" { - arrived_state.left = right; - arrived_state.right = left; - } else { - arrived_state.left = left; - arrived_state.right = right; + element.scroll_to_with_scroll_to_options(&scroll_options); } - }); - set_internal_x.set(scroll_left); - - let mut scroll_top = target.scroll_top() as f64; - - // patch for mobile compatibility - if target == document().unchecked_into::() && scroll_top == 0.0 { - scroll_top = document().body().expect("failed to get body").scroll_top() as f64; } - - let scroll_top_abs = scroll_top.abs(); - - directions.update(|directions| { - directions.top = scroll_top < internal_y.get_untracked(); - directions.bottom = scroll_top > internal_y.get_untracked(); - }); - - let top = scroll_top_abs <= offset.top; - let bottom = scroll_top_abs + target.client_height() as f64 - >= target.scroll_height() as f64 - offset.bottom - ARRIVED_STATE_THRESHOLD_PIXELS; - - // reverse columns and rows behave exactly the other way around, - // bottom is treated as top and top is treated as the negative version of bottom - arrived_state.update(|arrived_state| { - if display == "flex" && flex_direction == "column-reverse" { - arrived_state.top = bottom; - arrived_state.bottom = top; - } else { - arrived_state.top = top; - arrived_state.bottom = bottom; - } - }); - - set_internal_y.set(scroll_top); - } - }; - - let on_scroll_handler = { - let on_scroll = Rc::clone(&options.on_scroll); - - move |e: web_sys::Event| { - let target: web_sys::Element = event_target(&e); - - set_arrived_state(target); - set_is_scrolling.set(true); - on_scroll_end_debounced.clone()(e.clone()); - on_scroll.clone()(e); - } - }; - - let target = { - let signal = signal.clone(); - - Signal::derive(move || { - let element = signal.get(); - element.map(|element| element.into().unchecked_into::()) - }) - }; - - if throttle >= 0.0 { - let throttled_scroll_handler = use_throttle_fn_with_arg_and_options( - on_scroll_handler.clone(), - throttle, - ThrottleOptions { - trailing: true, - leading: false, - }, - ); - - let handler = move |e: web_sys::Event| { - throttled_scroll_handler.clone()(e); }; - let _ = use_event_listener_with_options::< - _, - Signal>, - web_sys::EventTarget, - _, - >( - target, - ev::scroll, - handler, - options.event_listener_options.clone(), - ); - } else { - let _ = use_event_listener_with_options::< - _, - Signal>, - web_sys::EventTarget, - _, - >( - target, - ev::scroll, - on_scroll_handler, - options.event_listener_options.clone(), - ); - } + let set_x = { + let scroll_to = scroll_to.clone(); + Box::new(move |x| scroll_to(Some(x), None)) + }; - let _ = use_event_listener_with_options::< - _, - Signal>, - web_sys::EventTarget, - _, - >( - target, - scrollend, - on_scroll_end, - options.event_listener_options, - ); + let set_y = Box::new(move |y| scroll_to(None, Some(y))); - let measure = Box::new(move || { - let el = signal.get_untracked(); - if let Some(el) = el { - let el = el.into(); - set_arrived_state(el); + let on_scroll_end = { + let on_stop = Rc::clone(&options.on_stop); + + move |e| { + if !is_scrolling.get_untracked() { + return; + } + + set_is_scrolling.set(false); + directions.update(|directions| { + directions.left = false; + directions.right = false; + directions.top = false; + directions.bottom = false; + on_stop.clone()(e); + }); + } + }; + + let throttle = options.throttle; + + let on_scroll_end_debounced = + use_debounce_fn_with_arg(on_scroll_end.clone(), throttle + options.idle); + + let offset = options.offset; + + let set_arrived_state = move |target: web_sys::Element| { + let style = window() + .get_computed_style(&target) + .expect("failed to get computed style"); + + if let Some(style) = style { + let display = style + .get_property_value("display") + .expect("failed to get display"); + let flex_direction = style + .get_property_value("flex-direction") + .expect("failed to get flex-direction"); + + let scroll_left = target.scroll_left() as f64; + let scroll_left_abs = scroll_left.abs(); + + directions.update(|directions| { + directions.left = scroll_left < internal_x.get_untracked(); + directions.right = scroll_left > internal_x.get_untracked(); + }); + + let left = scroll_left_abs <= offset.left; + let right = scroll_left_abs + target.client_width() as f64 + >= target.scroll_width() as f64 - offset.right - ARRIVED_STATE_THRESHOLD_PIXELS; + + arrived_state.update(|arrived_state| { + if display == "flex" && flex_direction == "row-reverse" { + arrived_state.left = right; + arrived_state.right = left; + } else { + arrived_state.left = left; + arrived_state.right = right; + } + }); + set_internal_x.set(scroll_left); + + let mut scroll_top = target.scroll_top() as f64; + + // patch for mobile compatibility + if target == document().unchecked_into::() && scroll_top == 0.0 { + scroll_top = document().body().expect("failed to get body").scroll_top() as f64; + } + + let scroll_top_abs = scroll_top.abs(); + + directions.update(|directions| { + directions.top = scroll_top < internal_y.get_untracked(); + directions.bottom = scroll_top > internal_y.get_untracked(); + }); + + let top = scroll_top_abs <= offset.top; + let bottom = scroll_top_abs + target.client_height() as f64 + >= target.scroll_height() as f64 - offset.bottom - ARRIVED_STATE_THRESHOLD_PIXELS; + + // reverse columns and rows behave exactly the other way around, + // bottom is treated as top and top is treated as the negative version of bottom + arrived_state.update(|arrived_state| { + if display == "flex" && flex_direction == "column-reverse" { + arrived_state.top = bottom; + arrived_state.bottom = top; + } else { + arrived_state.top = top; + arrived_state.bottom = bottom; + } + }); + + set_internal_y.set(scroll_top); + } + }; + + let on_scroll_handler = { + let on_scroll = Rc::clone(&options.on_scroll); + + move |e: web_sys::Event| { + let target: web_sys::Element = event_target(&e); + + set_arrived_state(target); + set_is_scrolling.set(true); + on_scroll_end_debounced.clone()(e.clone()); + on_scroll.clone()(e); + } + }; + + let target = { + let signal = signal.clone(); + + Signal::derive(move || { + let element = signal.get(); + element.map(|element| element.into().unchecked_into::()) + }) + }; + + if throttle >= 0.0 { + let throttled_scroll_handler = use_throttle_fn_with_arg_and_options( + on_scroll_handler.clone(), + throttle, + ThrottleOptions { + trailing: true, + leading: false, + }, + ); + + let handler = move |e: web_sys::Event| { + throttled_scroll_handler.clone()(e); + }; + + let _ = use_event_listener_with_options::< + _, + Signal>, + web_sys::EventTarget, + _, + >( + target, + ev::scroll, + handler, + options.event_listener_options.clone(), + ); + } else { + let _ = use_event_listener_with_options::< + _, + Signal>, + web_sys::EventTarget, + _, + >( + target, + ev::scroll, + on_scroll_handler, + options.event_listener_options.clone(), + ); } - }); + + let _ = use_event_listener_with_options::< + _, + Signal>, + web_sys::EventTarget, + _, + >( + target, + scrollend, + on_scroll_end, + options.event_listener_options, + ); + + let measure = Box::new(move || { + let el = signal.get_untracked(); + if let Some(el) = el { + let el = el.into(); + set_arrived_state(el); + } + }); + }} UseScrollReturn { x: internal_x.into(), From ecfe9b6a71d923148883a9d8174afadf45c317e9 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Wed, 16 Aug 2023 17:07:00 +0100 Subject: [PATCH 6/8] made use_scroll usable on the server --- src/use_scroll.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/use_scroll.rs b/src/use_scroll.rs index e7e7d2d..76d7995 100644 --- a/src/use_scroll.rs +++ b/src/use_scroll.rs @@ -378,7 +378,7 @@ where target, ev::scroll, handler, - options.event_listener_options.clone(), + options.event_listener_options.clone().unwrap_or_default(), ); } else { let _ = use_event_listener_with_options::< @@ -390,7 +390,7 @@ where target, ev::scroll, on_scroll_handler, - options.event_listener_options.clone(), + options.event_listener_options.clone().unwrap_or_default(), ); } @@ -403,7 +403,7 @@ where target, scrollend, on_scroll_end, - options.event_listener_options, + options.event_listener_options.unwrap_or_default(), ); let measure = Box::new(move || { @@ -454,7 +454,8 @@ pub struct UseScrollOptions { on_stop: Rc, /// Options passed to the `addEventListener("scroll", ...)` call - event_listener_options: web_sys::AddEventListenerOptions, + #[builder(into)] + event_listener_options: Option, /// When changing the `x` or `y` signals this specifies the scroll behaviour. /// Can be `Auto` (= not smooth) or `Smooth`. Defaults to `Auto`. From 660e115b0dad5b2989308d8f6f3e2e084392b8f5 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Thu, 31 Aug 2023 04:41:42 +0100 Subject: [PATCH 7/8] updated to leptos 0.5.0-beta2 --- Cargo.toml | 2 +- src/core/element_maybe_signal.rs | 16 ++++++++++++---- src/core/elements_maybe_signal.rs | 16 ++++++++++++---- src/core/position.rs | 2 +- src/use_scroll.rs | 24 +----------------------- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index da58b11..5168467 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/Synphonyte/leptos-use" homepage = "https://leptos-use.rs" [dependencies] -leptos = "0.5.0-beta" +leptos = "0.5.0-beta2" wasm-bindgen = "0.2" js-sys = "0.3" default-struct-builder = "0.5" diff --git a/src/core/element_maybe_signal.rs b/src/core/element_maybe_signal.rs index aaf5139..c368297 100644 --- a/src/core/element_maybe_signal.rs +++ b/src/core/element_maybe_signal.rs @@ -41,10 +41,12 @@ where } } -impl SignalGet> for ElementMaybeSignal +impl SignalGet for ElementMaybeSignal where T: Into + Clone + 'static, { + type Value = Option; + fn get(&self) -> Option { match self { Self::Static(t) => t.clone(), @@ -62,10 +64,12 @@ where } } -impl SignalWith> for ElementMaybeSignal +impl SignalWith for ElementMaybeSignal where T: Into + Clone + 'static, { + type Value = Option; + fn with(&self, f: impl FnOnce(&Option) -> O) -> O { match self { Self::Static(t) => f(t), @@ -83,10 +87,12 @@ where } } -impl SignalWithUntracked> for ElementMaybeSignal +impl SignalWithUntracked for ElementMaybeSignal where T: Into + Clone + 'static, { + type Value = Option; + fn with_untracked(&self, f: impl FnOnce(&Option) -> O) -> O { match self { Self::Static(t) => f(t), @@ -104,10 +110,12 @@ where } } -impl SignalGetUntracked> for ElementMaybeSignal +impl SignalGetUntracked for ElementMaybeSignal where T: Into + Clone + 'static, { + type Value = Option; + fn get_untracked(&self) -> Option { match self { Self::Static(t) => t.clone(), diff --git a/src/core/elements_maybe_signal.rs b/src/core/elements_maybe_signal.rs index d78dfc8..645d377 100644 --- a/src/core/elements_maybe_signal.rs +++ b/src/core/elements_maybe_signal.rs @@ -42,10 +42,12 @@ where } } -impl SignalGet>> for ElementsMaybeSignal +impl SignalGet for ElementsMaybeSignal where T: Into + Clone + 'static, { + type Value = Vec>; + fn get(&self) -> Vec> { match self { Self::Static(v) => v.clone(), @@ -63,10 +65,12 @@ where } } -impl SignalWith>> for ElementsMaybeSignal +impl SignalWith for ElementsMaybeSignal where T: Into + Clone + 'static, { + type Value = Vec>; + fn with(&self, f: impl FnOnce(&Vec>) -> O) -> O { match self { Self::Static(v) => f(v), @@ -84,10 +88,12 @@ where } } -impl SignalWithUntracked>> for ElementsMaybeSignal +impl SignalWithUntracked for ElementsMaybeSignal where T: Into + Clone + 'static, { + type Value = Vec>; + fn with_untracked(&self, f: impl FnOnce(&Vec>) -> O) -> O { match self { Self::Static(t) => f(t), @@ -105,10 +111,12 @@ where } } -impl SignalGetUntracked>> for ElementsMaybeSignal +impl SignalGetUntracked for ElementsMaybeSignal where T: Into + Clone + 'static, { + type Value = Vec>; + fn get_untracked(&self) -> Vec> { match self { Self::Static(t) => t.clone(), diff --git a/src/core/position.rs b/src/core/position.rs index c940540..595cc7b 100644 --- a/src/core/position.rs +++ b/src/core/position.rs @@ -1,4 +1,4 @@ -#[derive(Copy, Clone, Default)] +#[derive(Copy, Clone, Default, Debug)] pub struct Position { pub x: f64, pub y: f64, diff --git a/src/use_scroll.rs b/src/use_scroll.rs index 76d7995..cea850c 100644 --- a/src/use_scroll.rs +++ b/src/use_scroll.rs @@ -3,7 +3,7 @@ use crate::use_event_listener::use_event_listener_with_options; use crate::{use_debounce_fn_with_arg, use_throttle_fn_with_arg_and_options, ThrottleOptions}; use cfg_if::cfg_if; use default_struct_builder::DefaultBuilder; -use leptos::ev::EventDescriptor; +use leptos::ev::{scrollend, EventDescriptor}; use leptos::*; use std::borrow::Cow; use std::rc::Rc; @@ -523,25 +523,3 @@ pub struct ScrollOffset { pub right: f64, pub bottom: f64, } - -// TODO : remove when leptos merges PR https://github.com/leptos-rs/leptos/pull/1105 - -#[allow(non_camel_case_types)] -#[derive(Copy, Clone)] -struct scrollend; - -impl EventDescriptor for scrollend { - type EventType = web_sys::Event; - - #[inline(always)] - fn name(&self) -> Cow<'static, str> { - "scrollend".into() - } - - #[inline(always)] - fn event_delegation_key(&self) -> Cow<'static, str> { - "$$$scrollend".into() - } - - const BUBBLES: bool = false; -} From 84e99dbb9e3343cfc4aad46843d402ebfcde0522 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Thu, 31 Aug 2023 04:46:46 +0100 Subject: [PATCH 8/8] updated to leptos 0.5.0-beta2 --- examples/on_click_outside/Cargo.toml | 2 +- examples/signal_debounced/Cargo.toml | 2 +- examples/signal_throttled/Cargo.toml | 2 +- examples/ssr/Cargo.toml | 10 +++++----- examples/use_abs/Cargo.toml | 2 +- examples/use_active_element/Cargo.toml | 2 +- examples/use_breakpoints/Cargo.toml | 2 +- examples/use_ceil/Cargo.toml | 2 +- examples/use_color_mode/Cargo.toml | 2 +- examples/use_css_var/Cargo.toml | 2 +- examples/use_cycle_list/Cargo.toml | 2 +- examples/use_debounce_fn/Cargo.toml | 2 +- examples/use_document_visibility/Cargo.toml | 2 +- examples/use_draggable/Cargo.toml | 2 +- examples/use_drop_zone/Cargo.toml | 2 +- examples/use_element_hover/Cargo.toml | 2 +- examples/use_element_size/Cargo.toml | 2 +- examples/use_element_visibility/Cargo.toml | 2 +- examples/use_event_listener/Cargo.toml | 2 +- examples/use_favicon/Cargo.toml | 2 +- examples/use_floor/Cargo.toml | 2 +- examples/use_intersection_observer/Cargo.toml | 2 +- examples/use_interval/Cargo.toml | 2 +- examples/use_interval_fn/Cargo.toml | 2 +- examples/use_intl_number_format/Cargo.toml | 2 +- examples/use_media_query/Cargo.toml | 2 +- examples/use_mouse/Cargo.toml | 2 +- examples/use_mutation_observer/Cargo.toml | 2 +- examples/use_raf_fn/Cargo.toml | 2 +- examples/use_resize_observer/Cargo.toml | 2 +- examples/use_round/Cargo.toml | 2 +- examples/use_scroll/Cargo.toml | 2 +- examples/use_storage/Cargo.toml | 2 +- examples/use_throttle_fn/Cargo.toml | 2 +- examples/use_websocket/Cargo.toml | 2 +- examples/use_window_focus/Cargo.toml | 2 +- examples/use_window_scroll/Cargo.toml | 2 +- examples/watch_debounced/Cargo.toml | 2 +- examples/watch_pausable/Cargo.toml | 2 +- examples/watch_throttled/Cargo.toml | 2 +- src/use_scroll.rs | 3 +-- src/use_websocket.rs | 1 - 42 files changed, 45 insertions(+), 47 deletions(-) diff --git a/examples/on_click_outside/Cargo.toml b/examples/on_click_outside/Cargo.toml index 5342a89..3f36a8f 100644 --- a/examples/on_click_outside/Cargo.toml +++ b/examples/on_click_outside/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/signal_debounced/Cargo.toml b/examples/signal_debounced/Cargo.toml index 57eabb7..f8e87f5 100644 --- a/examples/signal_debounced/Cargo.toml +++ b/examples/signal_debounced/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/signal_throttled/Cargo.toml b/examples/signal_throttled/Cargo.toml index 36b1676..fe51254 100644 --- a/examples/signal_throttled/Cargo.toml +++ b/examples/signal_throttled/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/ssr/Cargo.toml b/examples/ssr/Cargo.toml index 2abd26b..15773d7 100644 --- a/examples/ssr/Cargo.toml +++ b/examples/ssr/Cargo.toml @@ -11,16 +11,16 @@ axum = { version = "0.6.4", optional = true } console_error_panic_hook = "0.1" console_log = "1" cfg-if = "1" -leptos = { version = "0.5.0-alpha2", features = ["nightly"] } -leptos_axum = { version = "0.5.0-alpha2", optional = true } -leptos_meta = { version = "0.5.0-alpha2", features = ["nightly"] } -leptos_router = { version = "0.5.0-alpha2", features = ["nightly"] } +leptos = { version = "0.5.0-beta2", features = ["nightly"] } +leptos_axum = { version = "0.5.0-beta2", optional = true } +leptos_meta = { version = "0.5.0-beta2", features = ["nightly"] } +leptos_router = { version = "0.5.0-beta2", features = ["nightly"] } leptos-use = { path = "../..", features = ["storage"] } log = "0.4" simple_logger = "4" tokio = { version = "1.25.0", optional = true } tower = { version = "0.4.13", optional = true } -tower-http = { version = "0.5.0-alpha2", features = ["fs"], optional = true } +tower-http = { version = "0.5.0-beta2", features = ["fs"], optional = true } wasm-bindgen = "=0.2.87" thiserror = "1.0.38" tracing = { version = "0.1.37", optional = true } diff --git a/examples/use_abs/Cargo.toml b/examples/use_abs/Cargo.toml index d758876..2275c7e 100644 --- a/examples/use_abs/Cargo.toml +++ b/examples/use_abs/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_active_element/Cargo.toml b/examples/use_active_element/Cargo.toml index a3ccfd1..77b76ee 100644 --- a/examples/use_active_element/Cargo.toml +++ b/examples/use_active_element/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_breakpoints/Cargo.toml b/examples/use_breakpoints/Cargo.toml index 9eb3186..134ca10 100644 --- a/examples/use_breakpoints/Cargo.toml +++ b/examples/use_breakpoints/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_ceil/Cargo.toml b/examples/use_ceil/Cargo.toml index 15189fa..2f9cb3b 100644 --- a/examples/use_ceil/Cargo.toml +++ b/examples/use_ceil/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_color_mode/Cargo.toml b/examples/use_color_mode/Cargo.toml index ad64682..5ca30d5 100644 --- a/examples/use_color_mode/Cargo.toml +++ b/examples/use_color_mode/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_css_var/Cargo.toml b/examples/use_css_var/Cargo.toml index 0360d48..80b941d 100644 --- a/examples/use_css_var/Cargo.toml +++ b/examples/use_css_var/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_cycle_list/Cargo.toml b/examples/use_cycle_list/Cargo.toml index 554fb87..02e9729 100644 --- a/examples/use_cycle_list/Cargo.toml +++ b/examples/use_cycle_list/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_debounce_fn/Cargo.toml b/examples/use_debounce_fn/Cargo.toml index f23c40f..9adec09 100644 --- a/examples/use_debounce_fn/Cargo.toml +++ b/examples/use_debounce_fn/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_document_visibility/Cargo.toml b/examples/use_document_visibility/Cargo.toml index 2b68975..85e031a 100644 --- a/examples/use_document_visibility/Cargo.toml +++ b/examples/use_document_visibility/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_draggable/Cargo.toml b/examples/use_draggable/Cargo.toml index faac6bf..11d3568 100644 --- a/examples/use_draggable/Cargo.toml +++ b/examples/use_draggable/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_drop_zone/Cargo.toml b/examples/use_drop_zone/Cargo.toml index 6ad6ef0..d7a8294 100644 --- a/examples/use_drop_zone/Cargo.toml +++ b/examples/use_drop_zone/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_element_hover/Cargo.toml b/examples/use_element_hover/Cargo.toml index 0f1ae6e..9d49ffb 100644 --- a/examples/use_element_hover/Cargo.toml +++ b/examples/use_element_hover/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_element_size/Cargo.toml b/examples/use_element_size/Cargo.toml index abd70cc..f69b1e4 100644 --- a/examples/use_element_size/Cargo.toml +++ b/examples/use_element_size/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_element_visibility/Cargo.toml b/examples/use_element_visibility/Cargo.toml index 9263fe3..9137a57 100644 --- a/examples/use_element_visibility/Cargo.toml +++ b/examples/use_element_visibility/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_event_listener/Cargo.toml b/examples/use_event_listener/Cargo.toml index e925492..bb0997f 100644 --- a/examples/use_event_listener/Cargo.toml +++ b/examples/use_event_listener/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_favicon/Cargo.toml b/examples/use_favicon/Cargo.toml index 12e7f37..46478dc 100644 --- a/examples/use_favicon/Cargo.toml +++ b/examples/use_favicon/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_floor/Cargo.toml b/examples/use_floor/Cargo.toml index 53b3cdb..0ff939f 100644 --- a/examples/use_floor/Cargo.toml +++ b/examples/use_floor/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_intersection_observer/Cargo.toml b/examples/use_intersection_observer/Cargo.toml index a2374fd..81a221c 100644 --- a/examples/use_intersection_observer/Cargo.toml +++ b/examples/use_intersection_observer/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_interval/Cargo.toml b/examples/use_interval/Cargo.toml index 407bd63..8dc1ed5 100644 --- a/examples/use_interval/Cargo.toml +++ b/examples/use_interval/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_interval_fn/Cargo.toml b/examples/use_interval_fn/Cargo.toml index 4f1f5f1..2136704 100644 --- a/examples/use_interval_fn/Cargo.toml +++ b/examples/use_interval_fn/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_intl_number_format/Cargo.toml b/examples/use_intl_number_format/Cargo.toml index 4822b27..1135e12 100644 --- a/examples/use_intl_number_format/Cargo.toml +++ b/examples/use_intl_number_format/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_media_query/Cargo.toml b/examples/use_media_query/Cargo.toml index 8579241..0abd8ce 100644 --- a/examples/use_media_query/Cargo.toml +++ b/examples/use_media_query/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_mouse/Cargo.toml b/examples/use_mouse/Cargo.toml index ef03a36..51aedb0 100644 --- a/examples/use_mouse/Cargo.toml +++ b/examples/use_mouse/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_mutation_observer/Cargo.toml b/examples/use_mutation_observer/Cargo.toml index ba7223e..96d9dff 100644 --- a/examples/use_mutation_observer/Cargo.toml +++ b/examples/use_mutation_observer/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_raf_fn/Cargo.toml b/examples/use_raf_fn/Cargo.toml index 3f7ff57..c2fd26b 100644 --- a/examples/use_raf_fn/Cargo.toml +++ b/examples/use_raf_fn/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_resize_observer/Cargo.toml b/examples/use_resize_observer/Cargo.toml index c4e04ac..fe0afc4 100644 --- a/examples/use_resize_observer/Cargo.toml +++ b/examples/use_resize_observer/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_round/Cargo.toml b/examples/use_round/Cargo.toml index 0b467fd..86ba230 100644 --- a/examples/use_round/Cargo.toml +++ b/examples/use_round/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_scroll/Cargo.toml b/examples/use_scroll/Cargo.toml index 2658228..7e1ff4c 100644 --- a/examples/use_scroll/Cargo.toml +++ b/examples/use_scroll/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_storage/Cargo.toml b/examples/use_storage/Cargo.toml index 462839e..dff5752 100644 --- a/examples/use_storage/Cargo.toml +++ b/examples/use_storage/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_throttle_fn/Cargo.toml b/examples/use_throttle_fn/Cargo.toml index 9bf0266..b9c0068 100644 --- a/examples/use_throttle_fn/Cargo.toml +++ b/examples/use_throttle_fn/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_websocket/Cargo.toml b/examples/use_websocket/Cargo.toml index e2cb5e2..d514c4e 100644 --- a/examples/use_websocket/Cargo.toml +++ b/examples/use_websocket/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_window_focus/Cargo.toml b/examples/use_window_focus/Cargo.toml index b6145ec..8d8886b 100644 --- a/examples/use_window_focus/Cargo.toml +++ b/examples/use_window_focus/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/use_window_scroll/Cargo.toml b/examples/use_window_scroll/Cargo.toml index 4cc6225..a887335 100644 --- a/examples/use_window_scroll/Cargo.toml +++ b/examples/use_window_scroll/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/watch_debounced/Cargo.toml b/examples/watch_debounced/Cargo.toml index 61a80d2..3d8bcae 100644 --- a/examples/watch_debounced/Cargo.toml +++ b/examples/watch_debounced/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/watch_pausable/Cargo.toml b/examples/watch_pausable/Cargo.toml index e1338e4..25aa12f 100644 --- a/examples/watch_pausable/Cargo.toml +++ b/examples/watch_pausable/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/examples/watch_throttled/Cargo.toml b/examples/watch_throttled/Cargo.toml index 9510b5f..12efd1d 100644 --- a/examples/watch_throttled/Cargo.toml +++ b/examples/watch_throttled/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.5.0-alpha2", features = ["nightly", "csr"] } +leptos = { version = "0.5.0-beta2", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" diff --git a/src/use_scroll.rs b/src/use_scroll.rs index cea850c..9913fb8 100644 --- a/src/use_scroll.rs +++ b/src/use_scroll.rs @@ -3,9 +3,8 @@ use crate::use_event_listener::use_event_listener_with_options; use crate::{use_debounce_fn_with_arg, use_throttle_fn_with_arg_and_options, ThrottleOptions}; use cfg_if::cfg_if; use default_struct_builder::DefaultBuilder; -use leptos::ev::{scrollend, EventDescriptor}; +use leptos::ev::scrollend; use leptos::*; -use std::borrow::Cow; use std::rc::Rc; use wasm_bindgen::JsCast; diff --git a/src/use_websocket.rs b/src/use_websocket.rs index f67b767..b8f6575 100644 --- a/src/use_websocket.rs +++ b/src/use_websocket.rs @@ -154,7 +154,6 @@ pub fn use_websocket_with_options( connect_ref.set_value({ let ws = ws_ref.get_value(); - let url = url; let unmounted = Rc::clone(&unmounted); Some(Rc::new(move || {