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