added examples for signal_...

This commit is contained in:
Maccesch 2023-07-27 23:53:26 +01:00
parent 9a998b1dd4
commit 2161f776e8
2 changed files with 48 additions and 6 deletions

View file

@ -1,12 +1,33 @@
use leptos::*;
use leptos_use::docs::demo_or_body;
use leptos_use::docs::{demo_or_body, Note};
use leptos_use::signal_debounced;
#[component]
fn Demo() -> impl IntoView {
// signal_debounced();
let (input, set_input) = create_signal("".to_string());
let debounced = signal_debounced(input, 1000.0);
view! {}
view! {
<div>
<input
type="text"
value=input
on:input=move |event| set_input(event_target_value(&event))
placeholder="Try to type quickly, then stop..."
/>
<Note>
Delay is set to 1000ms for this demo.
</Note>
<p>
Input signal:
{input}
</p>
<p>
Debounced signal:
{debounced}
</p>
</div>
}
}
fn main() {

View file

@ -1,12 +1,33 @@
use leptos::*;
use leptos_use::docs::demo_or_body;
use leptos_use::docs::{demo_or_body, Note};
use leptos_use::signal_throttled;
#[component]
fn Demo() -> impl IntoView {
// signal_throttled();
let (input, set_input) = create_signal("".to_string());
let throttled = signal_throttled(input, 1000.0);
view! {}
view! {
<div>
<input
type="text"
value=input
on:input=move |event| set_input(event_target_value(&event))
placeholder="Try to type quickly..."
/>
<Note>
Delay is set to 1000ms for this demo.
</Note>
<p>
Input signal:
{input}
</p>
<p>
Throttled signal:
{throttled}
</p>
</div>
}
}
fn main() {