mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-22 16:49:22 -05:00
chore: clippy
This commit is contained in:
parent
e35a09148f
commit
0d0d4616f9
6 changed files with 13 additions and 29 deletions
|
@ -76,7 +76,7 @@ members = [
|
|||
exclude = ["ssr", "use_webtransport_with_server"]
|
||||
|
||||
[workspace.dependencies]
|
||||
leptos = "0.7.0-beta"
|
||||
leptos = "0.7.0-gamma2"
|
||||
codee = "0.2"
|
||||
console_error_panic_hook = "0.1"
|
||||
console_log = "1"
|
||||
|
|
|
@ -97,13 +97,6 @@ pub trait IntoElementMaybeSignalType<T, Marker: ?Sized> {
|
|||
fn into_element_maybe_signal_type(self) -> ElementMaybeSignalType<T>;
|
||||
}
|
||||
|
||||
/// Identity
|
||||
// impl<T> IntoElementMaybeSignalType<T, ()> for ElementMaybeSignal<T> {
|
||||
// fn into_element_maybe_signal_type(self) -> ElementMaybeSignalType<T> {
|
||||
// self.inner
|
||||
// }
|
||||
// }
|
||||
|
||||
// From static element //////////////////////////////////////////////////////////////
|
||||
|
||||
/// Handles `window()` or `document()`
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use crate::{use_document, use_event_listener_with_options, use_window, UseEventListenerOptions};
|
||||
use leptos::ev::{blur, focus};
|
||||
use leptos::reactive::wrappers::read::Signal;
|
||||
use leptos::prelude::*;
|
||||
use leptos::reactive::wrappers::read::Signal;
|
||||
|
||||
/// Reactive `document.activeElement`
|
||||
///
|
||||
|
@ -33,10 +33,7 @@ use leptos::prelude::*;
|
|||
///
|
||||
/// On the server this returns a `Signal` that always contains the value `None`.
|
||||
pub fn use_active_element() -> Signal<Option<web_sys::Element>, LocalStorage> {
|
||||
let get_active_element = move || {
|
||||
use_document()
|
||||
.active_element()
|
||||
};
|
||||
let get_active_element = move || use_document().active_element();
|
||||
|
||||
let (active_element, set_active_element) = signal_local(get_active_element());
|
||||
|
||||
|
|
|
@ -72,13 +72,7 @@ use wasm_bindgen::JsValue;
|
|||
/// ```
|
||||
pub fn use_broadcast_channel<T, C>(
|
||||
name: &str,
|
||||
) -> UseBroadcastChannelReturn<
|
||||
T,
|
||||
impl Fn(&T) + Clone,
|
||||
impl Fn() + Clone,
|
||||
<C as Encoder<T>>::Error,
|
||||
<C as Decoder<T>>::Error,
|
||||
>
|
||||
) -> UseBroadcastChannelReturn<T, impl Fn(&T) + Clone, impl Fn() + Clone, C>
|
||||
where
|
||||
T: Send + Sync,
|
||||
C: Encoder<T, Encoded = String> + Decoder<T, Encoded = str>,
|
||||
|
@ -179,13 +173,12 @@ where
|
|||
}
|
||||
|
||||
/// Return type of [`use_broadcast_channel`].
|
||||
pub struct UseBroadcastChannelReturn<T, PFn, CFn, E, D>
|
||||
pub struct UseBroadcastChannelReturn<T, PFn, CFn, C>
|
||||
where
|
||||
T: Send + Sync + 'static,
|
||||
PFn: Fn(&T) + Clone,
|
||||
CFn: Fn() + Clone,
|
||||
E: Send + Sync + 'static,
|
||||
D: Send + Sync + 'static,
|
||||
C: Encoder<T> + Decoder<T>,
|
||||
{
|
||||
/// `true` if this browser supports `BroadcastChannel`s.
|
||||
pub is_supported: Signal<bool>,
|
||||
|
@ -203,12 +196,14 @@ where
|
|||
pub close: CFn,
|
||||
|
||||
/// Latest error as reported by the `messageerror` event.
|
||||
pub error: Signal<Option<UseBroadcastChannelError<E, D>>, LocalStorage>,
|
||||
pub error: Signal<Option<ErrorType<T, C>>, LocalStorage>,
|
||||
|
||||
/// Wether the channel is closed
|
||||
pub is_closed: Signal<bool>,
|
||||
}
|
||||
|
||||
type ErrorType<T, C> = UseBroadcastChannelError<<C as Encoder<T>>::Error, <C as Decoder<T>>::Error>;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UseBroadcastChannelError<E, D> {
|
||||
#[error("failed to post message")]
|
||||
|
|
|
@ -114,7 +114,7 @@ where
|
|||
|
||||
on_enter(UseDropZoneEvent {
|
||||
files: files
|
||||
.with_untracked(|files| files.into_iter().map(|f| f.deref().clone()).collect()),
|
||||
.with_untracked(|files| files.iter().map(|f| f.deref().clone()).collect()),
|
||||
event,
|
||||
});
|
||||
});
|
||||
|
@ -128,7 +128,7 @@ where
|
|||
|
||||
on_over(UseDropZoneEvent {
|
||||
files: files
|
||||
.with_untracked(|files| files.into_iter().map(|f| f.deref().clone()).collect()),
|
||||
.with_untracked(|files| files.iter().map(|f| f.deref().clone()).collect()),
|
||||
event,
|
||||
});
|
||||
});
|
||||
|
@ -147,7 +147,7 @@ where
|
|||
|
||||
on_leave(UseDropZoneEvent {
|
||||
files: files
|
||||
.with_untracked(|files| files.into_iter().map(|f| f.deref().clone()).collect()),
|
||||
.with_untracked(|files| files.iter().map(|f| f.deref().clone()).collect()),
|
||||
event,
|
||||
});
|
||||
});
|
||||
|
@ -164,7 +164,7 @@ where
|
|||
|
||||
on_drop(UseDropZoneEvent {
|
||||
files: files
|
||||
.with_untracked(|files| files.into_iter().map(|f| f.deref().clone()).collect()),
|
||||
.with_untracked(|files| files.iter().map(|f| f.deref().clone()).collect()),
|
||||
event,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -44,7 +44,6 @@ pub use web_sys::LockMode;
|
|||
///
|
||||
/// On the server this returns `Err(UseWebLockError::Server)` and the task is not executed.
|
||||
// #[doc(cfg(feature = "use_web_lock"))]
|
||||
|
||||
pub async fn use_web_lock<C, F, R>(name: &str, callback: C) -> Result<R, UseWebLockError>
|
||||
where
|
||||
C: FnOnce(web_sys::Lock) -> F + 'static,
|
||||
|
|
Loading…
Add table
Reference in a new issue