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; -}