mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-08 21:33:09 -05:00
ported new functions
This commit is contained in:
parent
d63f4f4b99
commit
1d1fac7065
4 changed files with 14 additions and 14 deletions
|
@ -135,14 +135,14 @@ use std::rc::Rc;
|
||||||
/// of `default`.
|
/// of `default`.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use leptos::*;
|
/// # use leptos::prelude::*;
|
||||||
/// # use leptos_use::{sync_signal_with_options, SyncSignalOptions};
|
/// # use leptos_use::{sync_signal_with_options, SyncSignalOptions};
|
||||||
/// # use std::str::FromStr;
|
/// # use std::str::FromStr;
|
||||||
/// #
|
/// #
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let (a, set_a) = create_signal("10".to_string());
|
/// let (a, set_a) = signal("10".to_string());
|
||||||
/// let (b, set_b) = create_signal(2);
|
/// let (b, set_b) = signal(2);
|
||||||
///
|
///
|
||||||
/// let stop = sync_signal_with_options(
|
/// let stop = sync_signal_with_options(
|
||||||
/// (a, set_a),
|
/// (a, set_a),
|
||||||
|
@ -158,7 +158,7 @@ use std::rc::Rc;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use leptos::*;
|
/// # use leptos::prelude::*;
|
||||||
/// # use leptos_use::{sync_signal_with_options, SyncSignalOptions};
|
/// # use leptos_use::{sync_signal_with_options, SyncSignalOptions};
|
||||||
/// # use std::str::FromStr;
|
/// # use std::str::FromStr;
|
||||||
/// #
|
/// #
|
||||||
|
@ -169,8 +169,8 @@ use std::rc::Rc;
|
||||||
///
|
///
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// let (a, set_a) = create_signal(Foo { bar: 10 });
|
/// let (a, set_a) = signal(Foo { bar: 10 });
|
||||||
/// let (b, set_b) = create_signal(2);
|
/// let (b, set_b) = signal(2);
|
||||||
///
|
///
|
||||||
/// let stop = sync_signal_with_options(
|
/// let stop = sync_signal_with_options(
|
||||||
/// (a, set_a),
|
/// (a, set_a),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::core::MaybeRwSignal;
|
use crate::core::MaybeRwSignal;
|
||||||
use leptos::*;
|
use leptos::prelude::*;
|
||||||
|
|
||||||
/// A boolean switcher with utility functions.
|
/// A boolean switcher with utility functions.
|
||||||
///
|
///
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub use web_sys::LockMode;
|
||||||
/// ## Usage
|
/// ## Usage
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use leptos::*;
|
/// # use leptos::prelude::*;
|
||||||
/// # use leptos_use::use_web_lock;
|
/// # use leptos_use::use_web_lock;
|
||||||
/// #
|
/// #
|
||||||
/// async fn my_process(_lock: web_sys::Lock) -> i32 {
|
/// async fn my_process(_lock: web_sys::Lock) -> i32 {
|
||||||
|
@ -31,7 +31,7 @@ pub use web_sys::LockMode;
|
||||||
///
|
///
|
||||||
/// # #[component]
|
/// # #[component]
|
||||||
/// # fn Demo() -> impl IntoView {
|
/// # fn Demo() -> impl IntoView {
|
||||||
/// spawn_local(async {
|
/// leptos::spawn::spawn_local(async {
|
||||||
/// let res = use_web_lock("my_lock", my_process).await;
|
/// let res = use_web_lock("my_lock", my_process).await;
|
||||||
/// assert!(matches!(res, Ok(42)));
|
/// assert!(matches!(res, Ok(42)));
|
||||||
/// });
|
/// });
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use default_struct_builder::DefaultBuilder;
|
use default_struct_builder::DefaultBuilder;
|
||||||
use leptos::ev::resize;
|
use leptos::ev::resize;
|
||||||
use leptos::*;
|
use leptos::prelude::*;
|
||||||
|
|
||||||
/// Reactive window size.
|
/// Reactive window size.
|
||||||
///
|
///
|
||||||
|
@ -45,8 +45,8 @@ pub fn use_window_size_with_options(options: UseWindowSizeOptions) -> UseWindowS
|
||||||
measure_type,
|
measure_type,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
let (width, set_width) = create_signal(initial_size.width);
|
let (width, set_width) = signal(initial_size.width);
|
||||||
let (height, set_height) = create_signal(initial_size.height);
|
let (height, set_height) = signal(initial_size.height);
|
||||||
|
|
||||||
let update;
|
let update;
|
||||||
|
|
||||||
|
@ -126,8 +126,8 @@ pub fn use_window_size_with_options(options: UseWindowSizeOptions) -> UseWindowS
|
||||||
if listen_orientation {
|
if listen_orientation {
|
||||||
let matches = use_media_query("(orientation: portrait)");
|
let matches = use_media_query("(orientation: portrait)");
|
||||||
|
|
||||||
create_effect(move |_| {
|
Effect::new(move |_| {
|
||||||
matches.track();
|
let _ = matches.get();
|
||||||
|
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue