mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 17:09:21 -05:00
Merge pull request #159 from Baptistemontan/fixed_untyped_into
Fixed an untyped into causing compilation error
This commit is contained in:
commit
cc6a4ff541
4 changed files with 10 additions and 14 deletions
|
@ -64,7 +64,7 @@ where
|
||||||
|
|
||||||
fn with<O>(&self, f: impl FnOnce(&Option<T>) -> O) -> O {
|
fn with<O>(&self, f: impl FnOnce(&Option<T>) -> O) -> O {
|
||||||
match self {
|
match self {
|
||||||
Self::Static(t) => f(&t),
|
Self::Static(t) => f(t),
|
||||||
Self::Dynamic(s) => {
|
Self::Dynamic(s) => {
|
||||||
let value = s.get();
|
let value = s.get();
|
||||||
f(&value)
|
f(&value)
|
||||||
|
@ -75,7 +75,7 @@ where
|
||||||
|
|
||||||
fn try_with<O>(&self, f: impl FnOnce(&Option<T>) -> O) -> Option<O> {
|
fn try_with<O>(&self, f: impl FnOnce(&Option<T>) -> O) -> Option<O> {
|
||||||
match self {
|
match self {
|
||||||
Self::Static(t) => Some(f(&t)),
|
Self::Static(t) => Some(f(t)),
|
||||||
Self::Dynamic(s) => s.try_with(f),
|
Self::Dynamic(s) => s.try_with(f),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ where
|
||||||
|
|
||||||
fn with_untracked<O>(&self, f: impl FnOnce(&Option<T>) -> O) -> O {
|
fn with_untracked<O>(&self, f: impl FnOnce(&Option<T>) -> O) -> O {
|
||||||
match self {
|
match self {
|
||||||
Self::Static(t) => f(&t),
|
Self::Static(t) => f(t),
|
||||||
Self::Dynamic(s) => s.with_untracked(f),
|
Self::Dynamic(s) => s.with_untracked(f),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ where
|
||||||
|
|
||||||
fn try_with_untracked<O>(&self, f: impl FnOnce(&Option<T>) -> O) -> Option<O> {
|
fn try_with_untracked<O>(&self, f: impl FnOnce(&Option<T>) -> O) -> Option<O> {
|
||||||
match self {
|
match self {
|
||||||
Self::Static(t) => Some(f(&t)),
|
Self::Static(t) => Some(f(t)),
|
||||||
Self::Dynamic(s) => s.try_with_untracked(f),
|
Self::Dynamic(s) => s.try_with_untracked(f),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,8 +447,8 @@ where
|
||||||
/// If specified this will override the default behavior.
|
/// If specified this will override the default behavior.
|
||||||
/// To get the default behaviour back you can call the provided `default_handler` function.
|
/// To get the default behaviour back you can call the provided `default_handler` function.
|
||||||
/// It takes two parameters:
|
/// It takes two parameters:
|
||||||
/// - `mode: ColorMode`: The color mode to change to.
|
/// - `mode: ColorMode`: The color mode to change to.
|
||||||
/// -`default_handler: Arc<dyn Fn(ColorMode)>`: The default handler that would have been called if the `on_changed` handler had not been specified.
|
/// -`default_handler: Arc<dyn Fn(ColorMode)>`: The default handler that would have been called if the `on_changed` handler had not been specified.
|
||||||
on_changed: OnChangedFn,
|
on_changed: OnChangedFn,
|
||||||
|
|
||||||
/// When provided, `useStorage` will be skipped.
|
/// When provided, `useStorage` will be skipped.
|
||||||
|
|
|
@ -52,12 +52,9 @@ where
|
||||||
{
|
{
|
||||||
use leptos::leptos_dom::helpers::TimeoutHandle;
|
use leptos::leptos_dom::helpers::TimeoutHandle;
|
||||||
use leptos::prelude::diagnostics::SpecialNonReactiveZone;
|
use leptos::prelude::diagnostics::SpecialNonReactiveZone;
|
||||||
use std::cell::Cell;
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
let delay = delay.into();
|
|
||||||
|
|
||||||
let timer = Arc::new(Mutex::new(None::<TimeoutHandle>));
|
let timer = Arc::new(Mutex::new(None::<TimeoutHandle>));
|
||||||
|
|
||||||
let clear = {
|
let clear = {
|
||||||
|
|
|
@ -64,7 +64,6 @@ pub fn use_web_notification_with_options(
|
||||||
let show = move |_: ShowOptions| ();
|
let show = move |_: ShowOptions| ();
|
||||||
let close = move || ();
|
let close = move || ();
|
||||||
} else {
|
} else {
|
||||||
use leptos::{spawn::spawn_local, prelude::diagnostics::SpecialNonReactiveZone};
|
|
||||||
use crate::use_event_listener;
|
use crate::use_event_listener;
|
||||||
use leptos::ev::visibilitychange;
|
use leptos::ev::visibilitychange;
|
||||||
use wasm_bindgen::closure::Closure;
|
use wasm_bindgen::closure::Closure;
|
||||||
|
@ -75,7 +74,7 @@ pub fn use_web_notification_with_options(
|
||||||
let on_click = Rc::clone(&options.on_click);
|
let on_click = Rc::clone(&options.on_click);
|
||||||
move |e: web_sys::Event| {
|
move |e: web_sys::Event| {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
let _z = SpecialNonReactiveZone::enter();
|
let _z = leptos::prelude::diagnostics::SpecialNonReactiveZone::enter();
|
||||||
|
|
||||||
on_click(e);
|
on_click(e);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +85,7 @@ pub fn use_web_notification_with_options(
|
||||||
let on_close = Rc::clone(&options.on_close);
|
let on_close = Rc::clone(&options.on_close);
|
||||||
move |e: web_sys::Event| {
|
move |e: web_sys::Event| {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
let _z = SpecialNonReactiveZone::enter();
|
let _z = leptos::prelude::diagnostics::SpecialNonReactiveZone::enter();
|
||||||
|
|
||||||
on_close(e);
|
on_close(e);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +96,7 @@ pub fn use_web_notification_with_options(
|
||||||
let on_error = Rc::clone(&options.on_error);
|
let on_error = Rc::clone(&options.on_error);
|
||||||
move |e: web_sys::Event| {
|
move |e: web_sys::Event| {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
let _z = SpecialNonReactiveZone::enter();
|
let _z = leptos::prelude::diagnostics::SpecialNonReactiveZone::enter();
|
||||||
|
|
||||||
on_error(e);
|
on_error(e);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +107,7 @@ pub fn use_web_notification_with_options(
|
||||||
let on_show = Rc::clone(&options.on_show);
|
let on_show = Rc::clone(&options.on_show);
|
||||||
move |e: web_sys::Event| {
|
move |e: web_sys::Event| {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
let _z = SpecialNonReactiveZone::enter();
|
let _z = leptos::prelude::diagnostics::SpecialNonReactiveZone::enter();
|
||||||
|
|
||||||
on_show(e);
|
on_show(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue