mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-22 16:49:22 -05:00
ported use_web_lock and use_window_size examples
This commit is contained in:
parent
0d0d4616f9
commit
c8236dfc37
4 changed files with 15 additions and 10 deletions
|
@ -5,7 +5,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
gloo-timers = { version = "0.3", features = ["futures"] }
|
||||
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
||||
leptos = { workspace = true, features = ["nightly", "csr"] }
|
||||
console_error_panic_hook = "0.1"
|
||||
console_log = "1"
|
||||
log = "0.4"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use gloo_timers::future::sleep;
|
||||
use leptos::*;
|
||||
use leptos::prelude::*;
|
||||
use leptos::task::spawn_local;
|
||||
use leptos_use::docs::demo_or_body;
|
||||
use leptos_use::use_web_lock;
|
||||
use std::time::Duration;
|
||||
|
@ -12,7 +13,7 @@ async fn my_process(_lock: web_sys::Lock) -> i32 {
|
|||
|
||||
#[component]
|
||||
fn Demo() -> impl IntoView {
|
||||
let (res, set_res) = create_signal("Not started yet".to_string());
|
||||
let (res, set_res) = signal("Not started yet".to_string());
|
||||
|
||||
let on_click = move |_| {
|
||||
set_res.set("Running...".to_string());
|
||||
|
@ -41,7 +42,9 @@ fn main() {
|
|||
_ = console_log::init_with_level(log::Level::Debug);
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
mount_to(demo_or_body(), || {
|
||||
let unmount_handle = leptos::mount::mount_to(demo_or_body(), || {
|
||||
view! { <Demo/> }
|
||||
})
|
||||
});
|
||||
|
||||
unmount_handle.forget();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
||||
leptos = { workspace = true, features = ["nightly", "csr"] }
|
||||
console_error_panic_hook = "0.1"
|
||||
console_log = "1"
|
||||
log = "0.4"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use leptos::*;
|
||||
use leptos::prelude::*;
|
||||
use leptos_use::docs::demo_or_body;
|
||||
use leptos_use::{use_window_size, UseWindowSizeReturn};
|
||||
|
||||
|
@ -7,7 +7,7 @@ fn Demo() -> impl IntoView {
|
|||
let UseWindowSizeReturn { width, height } = use_window_size();
|
||||
|
||||
view! {
|
||||
<p>{{ width }} x {{ height }}</p>
|
||||
<p>{ width } x { height }</p>
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,9 @@ fn main() {
|
|||
_ = console_log::init_with_level(log::Level::Debug);
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
mount_to(demo_or_body(), || {
|
||||
let unmount_handle = leptos::mount::mount_to(demo_or_body(), || {
|
||||
view! { <Demo/> }
|
||||
})
|
||||
});
|
||||
|
||||
unmount_handle.forget();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue