+
"Mutation Attribute: " {message.1}
}
/>
diff --git a/examples/use_resize_observer/rust-toolchain.toml b/examples/use_resize_observer/rust-toolchain.toml
index 271800c..292fe49 100644
--- a/examples/use_resize_observer/rust-toolchain.toml
+++ b/examples/use_resize_observer/rust-toolchain.toml
@@ -1,2 +1,2 @@
[toolchain]
-channel = "nightly"
\ No newline at end of file
+channel = "stable"
diff --git a/examples/use_resize_observer/src/main.rs b/examples/use_resize_observer/src/main.rs
index 8d66046..640bff6 100644
--- a/examples/use_resize_observer/src/main.rs
+++ b/examples/use_resize_observer/src/main.rs
@@ -9,7 +9,7 @@ fn Demo(cx: Scope) -> impl IntoView {
use_resize_observer(cx, el, move |entries, _| {
let rect = entries[0].content_rect();
- set_text(format!(
+ set_text.set(format!(
"width: {:.0}\nheight: {:.0}",
rect.width(),
rect.height()
@@ -22,7 +22,7 @@ fn Demo(cx: Scope) -> impl IntoView {
node_ref=el
readonly
class="resize rounded-md p-4 w-[200px] h-[100px] text-2xl leading-10"
- prop:value=text
+ prop:value=move || text.get()
/>
}
}
diff --git a/examples/use_round/rust-toolchain.toml b/examples/use_round/rust-toolchain.toml
index 271800c..292fe49 100644
--- a/examples/use_round/rust-toolchain.toml
+++ b/examples/use_round/rust-toolchain.toml
@@ -1,2 +1,2 @@
[toolchain]
-channel = "nightly"
\ No newline at end of file
+channel = "stable"
diff --git a/examples/use_round/src/main.rs b/examples/use_round/src/main.rs
index 645fbc4..34ca7fa 100644
--- a/examples/use_round/src/main.rs
+++ b/examples/use_round/src/main.rs
@@ -11,15 +11,15 @@ fn Demo(cx: Scope) -> impl IntoView {
view! { cx,
-
"Value: " {value}
-
"Rounded: " {result}
+
"Value: " {move|| value.get()}
+
"Rounded: " {move || result.get()}
}
}
diff --git a/examples/use_scroll/rust-toolchain.toml b/examples/use_scroll/rust-toolchain.toml
index 271800c..292fe49 100644
--- a/examples/use_scroll/rust-toolchain.toml
+++ b/examples/use_scroll/rust-toolchain.toml
@@ -1,2 +1,2 @@
[toolchain]
-channel = "nightly"
\ No newline at end of file
+channel = "stable"
diff --git a/examples/use_scroll/src/main.rs b/examples/use_scroll/src/main.rs
index 041782f..bb14e1b 100644
--- a/examples/use_scroll/src/main.rs
+++ b/examples/use_scroll/src/main.rs
@@ -7,7 +7,7 @@ fn Demo(cx: Scope) -> impl IntoView {
let el = create_node_ref(cx);
let (smooth, set_smooth) = create_signal(cx, false);
let behavior = Signal::derive(cx, move || {
- if smooth() {
+ if smooth.get() {
ScrollBehavior::Smooth
} else {
ScrollBehavior::Auto
@@ -56,7 +56,7 @@ fn Demo(cx: Scope) -> impl IntoView {
() {
set_x(num);
@@ -75,7 +75,7 @@ fn Demo(cx: Scope) -> impl IntoView {
() {
set_y(num);
@@ -94,8 +94,8 @@ fn Demo(cx: Scope) -> impl IntoView {
@@ -106,35 +106,35 @@ fn Demo(cx: Scope) -> impl IntoView {
"Top Arrived"
-
+
"Right Arrived"
-
+
"Bottom Arrived"
-
+
"Left Arrived"
-
+
"Scrolling Up"
-
+
"Scrolling Right"
-
+
"Scrolling Down"
-
+
"Scrolling Left"
-
+
diff --git a/examples/use_storage/rust-toolchain.toml b/examples/use_storage/rust-toolchain.toml
index 271800c..292fe49 100644
--- a/examples/use_storage/rust-toolchain.toml
+++ b/examples/use_storage/rust-toolchain.toml
@@ -1,2 +1,2 @@
[toolchain]
-channel = "nightly"
\ No newline at end of file
+channel = "stable"
diff --git a/examples/use_storage/src/main.rs b/examples/use_storage/src/main.rs
index f58a270..0b7fcdf 100644
--- a/examples/use_storage/src/main.rs
+++ b/examples/use_storage/src/main.rs
@@ -27,26 +27,26 @@ fn Demo(cx: Scope) -> impl IntoView {
view! { cx,
().unwrap() as u32)
type="number"
min="0"
@@ -57,7 +57,7 @@ fn Demo(cx: Scope) -> impl IntoView {
"Second ""use_storage"
":"
- { move || format!("{:#?}", state2()) }
+ { move || format!("{:#?}", state2.get()) }
"The values are persistant. When you reload the page the values will be the same."
diff --git a/examples/use_throttle_fn/rust-toolchain.toml b/examples/use_throttle_fn/rust-toolchain.toml
index 271800c..292fe49 100644
--- a/examples/use_throttle_fn/rust-toolchain.toml
+++ b/examples/use_throttle_fn/rust-toolchain.toml
@@ -1,2 +1,2 @@
[toolchain]
-channel = "nightly"
\ No newline at end of file
+channel = "stable"
diff --git a/examples/use_throttle_fn/src/main.rs b/examples/use_throttle_fn/src/main.rs
index 6c9e043..81b6377 100644
--- a/examples/use_throttle_fn/src/main.rs
+++ b/examples/use_throttle_fn/src/main.rs
@@ -7,12 +7,12 @@ fn Demo(cx: Scope) -> impl IntoView {
let (click_count, set_click_count) = create_signal(cx, 0);
let (throttled_count, set_throttled_count) = create_signal(cx, 0);
- let throttled_fn = use_throttle_fn(move || set_throttled_count(throttled_count() + 1), 1000.0);
+ let throttled_fn = use_throttle_fn(move || set_throttled_count.set(throttled_count.get_untracked() + 1), 1000.0);
view! { cx,
}
/// >
///
"Condition true"
diff --git a/src/use_favicon.rs b/src/use_favicon.rs
index 70a50ef..b1cde29 100644
--- a/src/use_favicon.rs
+++ b/src/use_favicon.rs
@@ -20,7 +20,7 @@ use wasm_bindgen::JsCast;
/// #
/// let (icon, set_icon) = use_favicon(cx);
///
-/// set_icon(Some("dark.png".to_string())); // change current icon
+/// set_icon.set(Some("dark.png".to_string())); // change current icon
/// #
/// # view! { cx, }
/// # }
@@ -44,7 +44,7 @@ use wasm_bindgen::JsCast;
/// cx,
/// UseFaviconOptions::default().new_icon(
/// Signal::derive(cx, move || {
-/// Some((if is_dark() { "dark.png" } else { "light.png" }).to_string())
+/// Some((if is_dark.get() { "dark.png" } else { "light.png" }).to_string())
/// }),
/// )
/// );
@@ -73,7 +73,7 @@ pub fn use_favicon_with_options(
let (favicon, set_favicon) = create_signal(cx, new_icon.get_untracked());
if matches!(&new_icon, MaybeSignal::Dynamic(_)) {
- create_effect(cx, move |_| set_favicon(new_icon.get()));
+ create_effect(cx, move |_| set_favicon.set(new_icon.get()));
}
let apply_icon = move |icon: &String| {
@@ -90,7 +90,7 @@ pub fn use_favicon_with_options(
}
};
- let _ = watch(cx, favicon, move |new_icon, prev_icon, _| {
+ let _ = watch(cx, move || favicon.get(), move |new_icon, prev_icon, _| {
if Some(new_icon) != prev_icon {
if let Some(new_icon) = new_icon {
apply_icon(new_icon);
diff --git a/src/use_intersection_observer.rs b/src/use_intersection_observer.rs
index b1c82ed..6056cb2 100644
--- a/src/use_intersection_observer.rs
+++ b/src/use_intersection_observer.rs
@@ -30,7 +30,7 @@ use wasm_bindgen::prelude::*;
/// cx,
/// el,
/// move |entries, _| {
-/// set_visible(entries[0].is_intersecting());
+/// set_visible.set(entries[0].is_intersecting());
/// },
/// );
///
@@ -184,7 +184,7 @@ where
move || {
cleanup();
- set_active(false);
+ set_active.set(false);
}
};
@@ -193,7 +193,7 @@ where
pause,
resume: move || {
cleanup();
- set_active(true);
+ set_active.set(true);
},
stop,
}
diff --git a/src/use_interval.rs b/src/use_interval.rs
index a6db996..1c5962e 100644
--- a/src/use_interval.rs
+++ b/src/use_interval.rs
@@ -55,11 +55,11 @@ where
let (counter, set_counter) = create_signal(cx, 0u64);
let update = move || set_counter.update(|count| *count += 1);
- let reset = move || set_counter(0);
+ let reset = move || set_counter.set(0);
let cb = move || {
update();
- callback.clone()(counter());
+ callback.clone()(counter.get());
};
let Pausable {
diff --git a/src/use_interval_fn.rs b/src/use_interval_fn.rs
index 30b2372..27e203a 100644
--- a/src/use_interval_fn.rs
+++ b/src/use_interval_fn.rs
@@ -78,7 +78,7 @@ where
let clean = clean.clone();
move || {
- set_active(false);
+ set_active.set(false);
clean();
}
};
@@ -91,7 +91,7 @@ where
return;
}
- set_active(true);
+ set_active.set(true);
if immediate_callback {
callback.clone()();
@@ -110,7 +110,7 @@ where
if matches!(interval, MaybeSignal::Dynamic(_)) {
let resume = resume.clone();
- let stop_watch = watch(cx, interval, move |_, _, _| {
+ let stop_watch = watch(cx, move || interval.get(), move |_, _, _| {
if is_active.get() {
resume();
}
diff --git a/src/use_media_query.rs b/src/use_media_query.rs
index 77309f7..5c09e9d 100644
--- a/src/use_media_query.rs
+++ b/src/use_media_query.rs
@@ -64,7 +64,7 @@ pub fn use_media_query(cx: Scope, query: impl Into
>) -> Sign
*media_query = window().match_media(&query.get()).unwrap_or(None);
if let Some(media_query) = media_query.as_ref() {
- set_matches(media_query.matches());
+ set_matches.set(media_query.matches());
remove_listener.replace(Some(Box::new(use_event_listener(
cx,
@@ -76,7 +76,7 @@ pub fn use_media_query(cx: Scope, query: impl Into>) -> Sign
.clone(),
))));
} else {
- set_matches(false);
+ set_matches.set(false);
}
}
};
diff --git a/src/use_mouse.rs b/src/use_mouse.rs
index ff022c1..13412f4 100644
--- a/src/use_mouse.rs
+++ b/src/use_mouse.rs
@@ -108,9 +108,9 @@ where
let result = coord_type.extract_mouse_coords(&event);
if let Some((x, y)) = result {
- set_x(x);
- set_y(y);
- set_source_type(UseMouseSourceType::Mouse);
+ set_x.set(x);
+ set_y.set(y);
+ set_source_type.set(UseMouseSourceType::Mouse);
}
}
};
@@ -137,9 +137,9 @@ where
);
if let Some((x, y)) = result {
- set_x(x);
- set_y(y);
- set_source_type(UseMouseSourceType::Touch);
+ set_x.set(x);
+ set_y.set(y);
+ set_source_type.set(UseMouseSourceType::Touch);
}
}
}
@@ -147,8 +147,8 @@ where
let initial_value = options.initial_value;
let reset = move || {
- set_x(initial_value.x);
- set_y(initial_value.y);
+ set_x.set(initial_value.x);
+ set_y.set(initial_value.y);
};
// TODO : event filters?
diff --git a/src/use_mutation_observer.rs b/src/use_mutation_observer.rs
index 07b39cc..511c851 100644
--- a/src/use_mutation_observer.rs
+++ b/src/use_mutation_observer.rs
@@ -110,7 +110,7 @@ where
move |targets, _, _| {
cleanup();
- if is_supported() && !targets.is_empty() {
+ if is_supported.get() && !targets.is_empty() {
let obs = web_sys::MutationObserver::new(closure_js.as_ref().unchecked_ref())
.expect("failed to create MutationObserver");
diff --git a/src/use_resize_observer.rs b/src/use_resize_observer.rs
index 5479625..cb96f7b 100644
--- a/src/use_resize_observer.rs
+++ b/src/use_resize_observer.rs
@@ -34,12 +34,12 @@ use wasm_bindgen::prelude::*;
/// el,
/// move |entries, observer| {
/// let rect = entries[0].content_rect();
-/// set_text(format!("width: {}\nheight: {}", rect.width(), rect.height()));
+/// set_text.set(format!("width: {}\nheight: {}", rect.width(), rect.height()));
/// },
/// );
///
/// view! { cx,
-/// { text }
+/// { move || text.get() }
/// }
/// # }
/// ```
@@ -112,7 +112,7 @@ where
move |targets, _, _| {
cleanup();
- if is_supported() && !targets.is_empty() {
+ if is_supported.get() && !targets.is_empty() {
let obs =
web_sys::ResizeObserver::new(closure_js.clone().as_ref().unchecked_ref())
.expect("failed to create ResizeObserver");
diff --git a/src/use_scroll.rs b/src/use_scroll.rs
index 189cdc9..f309a00 100644
--- a/src/use_scroll.rs
+++ b/src/use_scroll.rs
@@ -94,8 +94,8 @@ use wasm_bindgen::JsCast;
///
/// view! { cx,
/// "..."
-/// "Scroll right 10px"
-/// "Scroll down 10px"
+/// "Scroll right 10px"
+/// "Scroll down 10px"
/// }
/// # }
/// ```
@@ -140,10 +140,10 @@ use wasm_bindgen::JsCast;
/// # fn Demo(cx: Scope) -> impl IntoView {
/// # let element = create_node_ref(cx);
/// #
-/// let (smooth, set_smoot) = create_signal(cx, false);
+/// let (smooth, set_smooth) = create_signal(cx, false);
///
/// let behavior = Signal::derive(cx, move || {
-/// if smooth() { ScrollBehavior::Smooth } else { ScrollBehavior::Auto }
+/// if smooth.get() { ScrollBehavior::Smooth } else { ScrollBehavior::Auto }
/// });
///
/// let UseScrollReturn {
@@ -246,7 +246,7 @@ where
return;
}
- set_is_scrolling(false);
+ set_is_scrolling.set(false);
directions.update(|directions| {
directions.left = false;
directions.right = false;
@@ -298,7 +298,7 @@ where
arrived_state.right = right;
}
});
- set_internal_x(scroll_left);
+ set_internal_x.set(scroll_left);
let mut scroll_top = target.scroll_top() as f64;
@@ -330,7 +330,7 @@ where
}
});
- set_internal_y(scroll_top);
+ set_internal_y.set(scroll_top);
}
};
@@ -341,7 +341,7 @@ where
let target: web_sys::Element = event_target(&e);
set_arrived_state(target);
- set_is_scrolling(true);
+ set_is_scrolling.set(true);
on_scroll_end_debounced.clone()(e.clone());
on_scroll.clone()(e);
}
diff --git a/src/use_supported.rs b/src/use_supported.rs
index f8dc29c..9e2ec86 100644
--- a/src/use_supported.rs
+++ b/src/use_supported.rs
@@ -15,7 +15,7 @@ use leptos::*;
/// || JsValue::from("getBattery").js_in(&window().navigator())
/// );
///
-/// if is_supported() {
+/// if is_supported.get() {
/// // do something
/// }
/// # view! { cx, }
diff --git a/src/watch.rs b/src/watch.rs
index 2c15857..3f5b34e 100644
--- a/src/watch.rs
+++ b/src/watch.rs
@@ -22,18 +22,18 @@ use std::rc::Rc;
///
/// let stop = watch(
/// cx,
-/// num,
+/// move || num.get(),
/// move |num, _, _| {
/// log!("Number {}", num);
/// },
/// );
///
-/// set_num(1); // > "Number 1"
+/// set_num.set(1); // > "Number 1"
///
/// set_timeout_with_handle(move || {
/// stop(); // stop watching
///
-/// set_num(2); // (nothing happens)
+/// set_num.set(2); // (nothing happens)
/// }, Duration::from_millis(1000));
/// # view! { cx, }
/// # }
@@ -54,14 +54,14 @@ use std::rc::Rc;
///
/// watch_with_options(
/// cx,
-/// num,
+/// move || num.get(),
/// move |num, _, _| {
/// log!("Number {}", num);
/// },
/// WatchOptions::default().immediate(true),
/// ); // > "Number 0"
///
-/// set_num(1); // > "Number 1"
+/// set_num.set(1); // > "Number 1"
/// # view! { cx, }
/// # }
/// ```
@@ -79,7 +79,7 @@ use std::rc::Rc;
/// #
/// watch_with_options(
/// cx,
-/// num,
+/// move || num.get(),
/// move |num, _, _| {
/// log!("Number {}", num);
/// },
@@ -98,7 +98,7 @@ use std::rc::Rc;
/// #
/// watch_with_options(
/// cx,
-/// num,
+/// move || num.get(),
/// move |num, _, _| {
/// log!("number {}", num);
/// },
@@ -162,7 +162,7 @@ where
create_filter_wrapper(options.filter.filter_fn(), wrapped_callback.clone());
create_effect(cx, move |did_run_before| {
- if !is_active() {
+ if !is_active.get() {
return;
}
@@ -187,7 +187,7 @@ where
});
move || {
- set_active(false);
+ set_active.set(false);
}
}
diff --git a/src/watch_debounced.rs b/src/watch_debounced.rs
index 198586f..a836c55 100644
--- a/src/watch_debounced.rs
+++ b/src/watch_debounced.rs
@@ -19,7 +19,7 @@ use leptos::*;
/// #
/// watch_debounced(
/// cx,
-/// source,
+/// move || source.get(),
/// move |_, _, _| {
/// log!("changed!");
/// },
@@ -43,7 +43,7 @@ use leptos::*;
/// #
/// watch_debounced_with_options(
/// cx,
-/// source,
+/// move || source.get(),
/// move |_, _, _| {
/// log!("changed!");
/// },
diff --git a/src/watch_pausable.rs b/src/watch_pausable.rs
index fcda2a3..84d87fb 100644
--- a/src/watch_pausable.rs
+++ b/src/watch_pausable.rs
@@ -23,21 +23,21 @@ use leptos::*;
/// ..
/// } = watch_pausable(
/// cx,
-/// source,
+/// move || source.get(),
/// |v, _, _| {
/// log!("Changed to {}", v);
/// },
/// );
///
-/// set_source("bar".to_string()); // > "Changed to bar"
+/// set_source.set("bar".to_string()); // > "Changed to bar"
///
/// pause();
///
-/// set_source("foobar".to_string()); // (nothing happens)
+/// set_source.set("foobar".to_string()); // (nothing happens)
///
/// resume();
///
-/// set_source("hello".to_string()); // > "Changed to hello"
+/// set_source.set("hello".to_string()); // > "Changed to hello"
/// # view! { cx, }
/// # }
/// ```
@@ -87,11 +87,11 @@ where
let stop = watch_with_options(cx, deps, pausable_callback, options);
let pause = move || {
- set_active(false);
+ set_active.set(false);
};
let resume = move || {
- set_active(true);
+ set_active.set(true);
};
WatchPausableReturn {
diff --git a/src/watch_throttled.rs b/src/watch_throttled.rs
index 496a577..4e02172 100644
--- a/src/watch_throttled.rs
+++ b/src/watch_throttled.rs
@@ -19,7 +19,7 @@ use leptos::*;
/// #
/// watch_throttled(
/// cx,
-/// source,
+/// move || source.get(),
/// move |_, _, _| {
/// log!("changed!");
/// },
@@ -43,7 +43,7 @@ use leptos::*;
/// #
/// watch_throttled_with_options(
/// cx,
-/// source,
+/// move || source.get(),
/// move |_, _, _| {
/// log!("changed!");
/// },
diff --git a/src/whenever.rs b/src/whenever.rs
index 670d8a0..13f0df8 100644
--- a/src/whenever.rs
+++ b/src/whenever.rs
@@ -12,7 +12,7 @@ use leptos::*;
/// # pub fn Demo(cx: Scope) -> impl IntoView {
/// let (is_ready, set_ready) = create_signal(cx, false);
///
-/// whenever(cx, is_ready, |v, _, _| log!("{}", v));
+/// whenever(cx, move || is_ready.get(), |v, _, _| log!("{}", v));
/// #
/// # view! { cx, }
/// # }
@@ -28,7 +28,7 @@ use leptos::*;
/// #
/// # pub fn Demo(cx: Scope) -> impl IntoView {
/// # let (is_ready, set_ready) = create_signal(cx, false);
-/// whenever(cx, is_ready, |value, prev_value, _| {
+/// whenever(cx, move || is_ready.get(), |value, prev_value, _| {
/// log!("before: {prev_value:?}; now: {value}");
/// });
/// #
@@ -48,7 +48,7 @@ use leptos::*;
/// # let (counter, set_counter) = create_signal(cx, 0);
/// whenever(
/// cx,
-/// move || counter() == 7,
+/// move || counter.get() == 7,
/// |_, _, _| log!("counter is 7 now!"),
/// );
/// #
@@ -68,7 +68,7 @@ use leptos::*;
/// # let (counter, set_counter) = create_signal(cx, 0);
/// whenever_with_options(
/// cx,
-/// move || counter() == 7,
+/// move || counter.get() == 7,
/// |_, _, _| log!("counter is 7 now!"),
/// WatchOptions::default().immediate(true),
/// );