mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
added examples for signal_...
This commit is contained in:
parent
9a998b1dd4
commit
2161f776e8
2 changed files with 48 additions and 6 deletions
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue