mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 09:09:21 -05:00
removed a bunch of warnings and test compile errors
This commit is contained in:
parent
3e8fd64aa5
commit
c42605c1ad
14 changed files with 26 additions and 36 deletions
|
@ -26,9 +26,9 @@ http1 = { version = "1", optional = true, package = "http" }
|
||||||
http0_2 = { version = "0.2", optional = true, package = "http" }
|
http0_2 = { version = "0.2", optional = true, package = "http" }
|
||||||
js-sys = "0.3"
|
js-sys = "0.3"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
leptos = { version = "0.7.0-beta" }
|
leptos = { version = "0.7.0-beta", git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" }
|
||||||
leptos_axum = { version = "0.7.0-beta", optional = true }
|
leptos_axum = { version = "0.7.0-beta", optional = true, git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" }
|
||||||
leptos_actix = { version = "0.6", optional = true }
|
leptos_actix = { version = "0.7.0-beta", optional = true, git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" }
|
||||||
leptos-spin = { version = "0.2", optional = true }
|
leptos-spin = { version = "0.2", optional = true }
|
||||||
num = { version = "0.4", optional = true }
|
num = { version = "0.4", optional = true }
|
||||||
paste = "1"
|
paste = "1"
|
||||||
|
@ -131,7 +131,7 @@ features = [
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
getrandom = { version = "0.2", features = ["js"] }
|
getrandom = { version = "0.2", features = ["js"] }
|
||||||
leptos_meta = "0.7.0-beta"
|
leptos_meta = { version = "0.7.0-beta", git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
codee = { version = "0.1", features = ["json_serde", "msgpack_serde", "base64", "prost"] }
|
codee = { version = "0.1", features = ["json_serde", "msgpack_serde", "base64", "prost"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|
|
@ -9,7 +9,7 @@ macro_rules! use_partial_cmp {
|
||||||
S: Into<MaybeSignal<C>>,
|
S: Into<MaybeSignal<C>>,
|
||||||
C: Send + Sync + 'static,
|
C: Send + Sync + 'static,
|
||||||
for<'a> &'a C: IntoIterator<Item = &'a N>,
|
for<'a> &'a C: IntoIterator<Item = &'a N>,
|
||||||
N: PartialOrd + Clone + Send + Sync,
|
N: PartialOrd + Clone + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let container = container.into();
|
let container = container.into();
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ macro_rules! use_simple_math {
|
||||||
pub fn [<use_ $fn_name>]<S, N>(x: S) -> Signal<N>
|
pub fn [<use_ $fn_name>]<S, N>(x: S) -> Signal<N>
|
||||||
where
|
where
|
||||||
S: Into<MaybeSignal<N>> + Send + Sync,
|
S: Into<MaybeSignal<N>> + Send + Sync,
|
||||||
N: Float + Send + Sync,
|
N: Float + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let x = x.into();
|
let x = x.into();
|
||||||
Signal::derive(move || x.get().$fn_name())
|
Signal::derive(move || x.get().$fn_name())
|
||||||
|
|
|
@ -6,7 +6,6 @@ use codee::{CodecError, Decoder, Encoder};
|
||||||
use default_struct_builder::DefaultBuilder;
|
use default_struct_builder::DefaultBuilder;
|
||||||
use leptos::prelude::wrappers::read::Signal;
|
use leptos::prelude::wrappers::read::Signal;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use send_wrapper::SendWrapper;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasm_bindgen::JsValue;
|
use wasm_bindgen::JsValue;
|
||||||
|
@ -199,6 +198,7 @@ where
|
||||||
#[cfg(not(feature = "ssr"))]
|
#[cfg(not(feature = "ssr"))]
|
||||||
{
|
{
|
||||||
use crate::{use_event_listener, use_window, watch_with_options, WatchOptions};
|
use crate::{use_event_listener, use_window, watch_with_options, WatchOptions};
|
||||||
|
use send_wrapper::SendWrapper;
|
||||||
|
|
||||||
// Get storage API
|
// Get storage API
|
||||||
let storage = storage_type
|
let storage = storage_type
|
||||||
|
|
|
@ -177,7 +177,7 @@ where
|
||||||
let mut stop_watch_right = None;
|
let mut stop_watch_right = None;
|
||||||
|
|
||||||
if matches!(direction, SyncDirection::Both | SyncDirection::LeftToRight) {
|
if matches!(direction, SyncDirection::Both | SyncDirection::LeftToRight) {
|
||||||
stop_watch_left = Some(watch(
|
stop_watch_left = Some(Effect::watch(
|
||||||
move || left.get(),
|
move || left.get(),
|
||||||
move |new_value, _, _| {
|
move |new_value, _, _| {
|
||||||
let new_value = (*transform_ltr)(new_value);
|
let new_value = (*transform_ltr)(new_value);
|
||||||
|
@ -191,7 +191,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(direction, SyncDirection::Both | SyncDirection::RightToLeft) {
|
if matches!(direction, SyncDirection::Both | SyncDirection::RightToLeft) {
|
||||||
stop_watch_right = Some(watch(
|
stop_watch_right = Some(Effect::watch(
|
||||||
move || right.get(),
|
move || right.get(),
|
||||||
move |new_value, _, _| {
|
move |new_value, _, _| {
|
||||||
let new_value = (*transform_rtl)(new_value);
|
let new_value = (*transform_rtl)(new_value);
|
||||||
|
@ -206,10 +206,10 @@ where
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
if let Some(stop_watch_left) = &stop_watch_left {
|
if let Some(stop_watch_left) = &stop_watch_left {
|
||||||
stop_watch_left();
|
stop_watch_left.stop();
|
||||||
}
|
}
|
||||||
if let Some(stop_watch_right) = &stop_watch_right {
|
if let Some(stop_watch_right) = &stop_watch_right {
|
||||||
stop_watch_right();
|
stop_watch_right.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ where
|
||||||
let _ = {
|
let _ = {
|
||||||
let set = set.clone();
|
let set = set.clone();
|
||||||
|
|
||||||
watch(move || list.get(), move |_, _, _| set(index.get()), false)
|
Effect::watch(move || list.get(), move |_, _, _| set(index.get()), false)
|
||||||
};
|
};
|
||||||
|
|
||||||
UseCycleListReturn {
|
UseCycleListReturn {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use leptos::prelude::wrappers::read::Signal;
|
use leptos::prelude::wrappers::read::Signal;
|
||||||
use send_wrapper::SendWrapper;
|
|
||||||
|
|
||||||
/// Reactive [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent).
|
/// Reactive [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent).
|
||||||
/// Provide web developers with information from the physical orientation of
|
/// Provide web developers with information from the physical orientation of
|
||||||
|
|
|
@ -99,7 +99,7 @@ pub fn use_display_media_with_options(
|
||||||
set_enabled.set(false);
|
set_enabled.set(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = watch(
|
Effect::watch(
|
||||||
move || enabled.get(),
|
move || enabled.get(),
|
||||||
move |enabled, _, _| {
|
move |enabled, _, _| {
|
||||||
if *enabled {
|
if *enabled {
|
||||||
|
|
|
@ -182,7 +182,7 @@ where
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
let _ = watch(
|
Effect::watch(
|
||||||
move || is_element_visible.get(),
|
move || is_element_visible.get(),
|
||||||
move |visible, prev_visible, _| {
|
move |visible, prev_visible, _| {
|
||||||
if *visible && !prev_visible.copied().unwrap_or_default() {
|
if *visible && !prev_visible.copied().unwrap_or_default() {
|
||||||
|
@ -192,7 +192,7 @@ where
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ = watch(
|
Effect::watch(
|
||||||
move || state.arrived_state.get().get_direction(direction),
|
move || state.arrived_state.get().get_direction(direction),
|
||||||
move |arrived, prev_arrived, _| {
|
move |arrived, prev_arrived, _| {
|
||||||
if let Some(prev_arrived) = prev_arrived {
|
if let Some(prev_arrived) = prev_arrived {
|
||||||
|
|
|
@ -3,7 +3,6 @@ use cfg_if::cfg_if;
|
||||||
use default_struct_builder::DefaultBuilder;
|
use default_struct_builder::DefaultBuilder;
|
||||||
use leptos::prelude::wrappers::read::Signal;
|
use leptos::prelude::wrappers::read::Signal;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use send_wrapper::SendWrapper;
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
||||||
|
@ -101,6 +100,8 @@ where
|
||||||
let cleanup = || {};
|
let cleanup = || {};
|
||||||
let stop = || {};
|
let stop = || {};
|
||||||
} else {
|
} else {
|
||||||
|
use send_wrapper::SendWrapper;
|
||||||
|
|
||||||
let closure_js = Closure::<dyn FnMut(js_sys::Array, web_sys::IntersectionObserver)>::new(
|
let closure_js = Closure::<dyn FnMut(js_sys::Array, web_sys::IntersectionObserver)>::new(
|
||||||
move |entries: js_sys::Array, observer| {
|
move |entries: js_sys::Array, observer| {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
|
|
|
@ -129,7 +129,7 @@ where
|
||||||
if matches!(interval, MaybeSignal::Dynamic(_)) {
|
if matches!(interval, MaybeSignal::Dynamic(_)) {
|
||||||
let resume = resume.clone();
|
let resume = resume.clone();
|
||||||
|
|
||||||
let stop_watch = watch(
|
let effect = Effect::watch(
|
||||||
move || interval.get(),
|
move || interval.get(),
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
if is_active.get() {
|
if is_active.get() {
|
||||||
|
@ -138,7 +138,7 @@ where
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
on_cleanup(stop_watch);
|
on_cleanup(move || effect.stop());
|
||||||
}
|
}
|
||||||
|
|
||||||
on_cleanup({
|
on_cleanup({
|
||||||
|
|
|
@ -2,7 +2,6 @@ use crate::core::ElementsMaybeSignal;
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use default_struct_builder::DefaultBuilder;
|
use default_struct_builder::DefaultBuilder;
|
||||||
use leptos::prelude::wrappers::read::Signal;
|
use leptos::prelude::wrappers::read::Signal;
|
||||||
use send_wrapper::SendWrapper;
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
||||||
|
@ -86,6 +85,7 @@ where
|
||||||
#[cfg(not(feature = "ssr"))]
|
#[cfg(not(feature = "ssr"))]
|
||||||
{
|
{
|
||||||
use crate::js;
|
use crate::js;
|
||||||
|
use send_wrapper::SendWrapper;
|
||||||
|
|
||||||
let closure_js = Closure::<dyn FnMut(js_sys::Array, web_sys::MutationObserver)>::new(
|
let closure_js = Closure::<dyn FnMut(js_sys::Array, web_sys::MutationObserver)>::new(
|
||||||
move |entries: js_sys::Array, observer| {
|
move |entries: js_sys::Array, observer| {
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub fn use_user_media_with_options(
|
||||||
set_enabled.set(false);
|
set_enabled.set(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = watch(
|
Effect::watch(
|
||||||
move || enabled.get(),
|
move || enabled.get(),
|
||||||
move |enabled, _, _| {
|
move |enabled, _, _| {
|
||||||
if *enabled {
|
if *enabled {
|
||||||
|
|
|
@ -53,7 +53,7 @@ macro_rules! signal_filtered {
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ = watch(move || value.get(), move |_, _, _| update(), false);
|
Effect::watch(move || value.get(), move |_, _, _| update(), false);
|
||||||
|
|
||||||
filtered.into()
|
filtered.into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ where
|
||||||
let filtered_callback =
|
let filtered_callback =
|
||||||
create_filter_wrapper(options.filter.filter_fn(), wrapped_callback.clone());
|
create_filter_wrapper(options.filter.filter_fn(), wrapped_callback.clone());
|
||||||
|
|
||||||
leptos::prelude::watch(
|
let effect = Effect::watch(
|
||||||
deps,
|
deps,
|
||||||
move |deps_value, previous_deps_value, did_run_before| {
|
move |deps_value, previous_deps_value, did_run_before| {
|
||||||
cur_deps_value.replace(Some(deps_value.clone()));
|
cur_deps_value.replace(Some(deps_value.clone()));
|
||||||
|
@ -144,7 +144,9 @@ where
|
||||||
prev_callback_value.replace(callback_value);
|
prev_callback_value.replace(callback_value);
|
||||||
},
|
},
|
||||||
options.immediate,
|
options.immediate,
|
||||||
)
|
);
|
||||||
|
|
||||||
|
move || effect.stop()
|
||||||
|
|
||||||
// create_effect(move |did_run_before| {
|
// create_effect(move |did_run_before| {
|
||||||
// if !is_active.get() {
|
// if !is_active.get() {
|
||||||
|
@ -186,15 +188,3 @@ impl WatchOptions {
|
||||||
filter
|
filter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deprecated(since = "0.7.0", note = "Use `leptos::watch` instead")]
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn watch<W, T, DFn, CFn>(deps: DFn, callback: CFn) -> impl Fn() + Clone
|
|
||||||
where
|
|
||||||
DFn: Fn() -> W + 'static,
|
|
||||||
CFn: Fn(&W, Option<&W>, Option<T>) -> T + Clone + 'static,
|
|
||||||
W: Clone + 'static,
|
|
||||||
T: Clone + 'static,
|
|
||||||
{
|
|
||||||
leptos::prelude::watch(deps, callback, false)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue