mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-22 22:09:22 -05:00
save
This commit is contained in:
parent
c57748f9ea
commit
99f585440b
5 changed files with 16 additions and 9 deletions
|
@ -15,3 +15,6 @@ thaw = { version = "0.3.1", path = "./thaw" }
|
|||
thaw_components = { version = "0.1.1", path = "./thaw_components" }
|
||||
thaw_macro = { version = "0.1.0", path = "./thaw_macro" }
|
||||
thaw_utils = { version = "0.0.3", path = "./thaw_utils" }
|
||||
|
||||
leptos = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" }
|
||||
leptos_meta = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" }
|
|
@ -12,7 +12,7 @@ license = "MIT"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
leptos = { version = "0.6.10" }
|
||||
leptos = { workspace = true }
|
||||
leptos_meta = { version = "0.6.10", optional = true }
|
||||
web-sys = "0.3.69"
|
||||
wasm-bindgen = "0.2.92"
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
use ::wasm_bindgen::{prelude::Closure, JsCast};
|
||||
use leptos::{html::AnyElement, *};
|
||||
use leptos::{
|
||||
ev,
|
||||
tachys::{renderer::DomRenderer, view::any_view::AnyView},
|
||||
};
|
||||
use std::ops::Deref;
|
||||
use web_sys::EventTarget;
|
||||
|
||||
pub fn add_event_listener<E: ev::EventDescriptor + 'static>(
|
||||
target: HtmlElement<AnyElement>,
|
||||
pub fn add_event_listener<E>(
|
||||
target: impl DomRenderer,
|
||||
event: E,
|
||||
cb: impl Fn(E::EventType) + 'static,
|
||||
) -> EventListenerHandle
|
||||
where
|
||||
E: ev::EventDescriptor + 'static,
|
||||
E::EventType: JsCast,
|
||||
{
|
||||
add_event_listener_untyped(target, &event.name(), move |e| {
|
||||
|
@ -31,12 +35,12 @@ impl EventListenerHandle {
|
|||
}
|
||||
|
||||
fn add_event_listener_untyped(
|
||||
target: HtmlElement<AnyElement>,
|
||||
target: impl DomRenderer,
|
||||
event_name: &str,
|
||||
cb: impl Fn(web_sys::Event) + 'static,
|
||||
) -> EventListenerHandle {
|
||||
fn wel(
|
||||
target: HtmlElement<AnyElement>,
|
||||
target: impl DomRenderer,
|
||||
cb: Box<dyn FnMut(web_sys::Event)>,
|
||||
event_name: &str,
|
||||
) -> EventListenerHandle {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use leptos::{MaybeSignal, Memo, ReadSignal, RwSignal, Signal};
|
||||
use leptos::prelude::{MaybeSignal, Memo, ReadSignal, RwSignal, Signal};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
pub struct OptionalProp<T>(Option<T>);
|
||||
|
@ -99,7 +99,7 @@ impl<T> From<Option<T>> for OptionalProp<T> {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::OptionalProp;
|
||||
use leptos::MaybeSignal;
|
||||
use leptos::prelude::MaybeSignal;
|
||||
|
||||
#[test]
|
||||
fn from() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use leptos::{leptos_dom::helpers::TimeoutHandle, *};
|
||||
use leptos::{leptos_dom::helpers::TimeoutHandle, prelude::*};
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn throttle(cb: impl Fn() + 'static, duration: Duration) -> impl Fn() -> () {
|
||||
|
|
Loading…
Add table
Reference in a new issue