mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
added use_to_string
This commit is contained in:
parent
880eca30da
commit
e529d110bc
6 changed files with 31 additions and 0 deletions
|
@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### New Functions 🚀
|
### New Functions 🚀
|
||||||
|
|
||||||
|
- `use_to_string`
|
||||||
- `is_err`
|
- `is_err`
|
||||||
- `is_ok`
|
- `is_ok`
|
||||||
- `is_none`
|
- `is_none`
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
- [use_debounce_fn](utilities/use_debounce_fn.md)
|
- [use_debounce_fn](utilities/use_debounce_fn.md)
|
||||||
- [use_supported](utilities/use_supported.md)
|
- [use_supported](utilities/use_supported.md)
|
||||||
- [use_throttle_fn](utilities/use_throttle_fn.md)
|
- [use_throttle_fn](utilities/use_throttle_fn.md)
|
||||||
|
- [use_to_string](utilities/use_to_string.md)
|
||||||
|
|
||||||
# Intl
|
# Intl
|
||||||
|
|
||||||
|
|
3
docs/book/src/utilities/use_to_string.md
Normal file
3
docs/book/src/utilities/use_to_string.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# use_to_string
|
||||||
|
|
||||||
|
<!-- cmdrun python3 ../extract_doc_comment.py use_to_string -->
|
|
@ -36,6 +36,7 @@ members = [
|
||||||
"use_scroll",
|
"use_scroll",
|
||||||
"use_storage",
|
"use_storage",
|
||||||
"use_throttle_fn",
|
"use_throttle_fn",
|
||||||
|
"use_to_string",
|
||||||
"use_websocket",
|
"use_websocket",
|
||||||
"use_window_focus",
|
"use_window_focus",
|
||||||
"use_window_scroll",
|
"use_window_scroll",
|
||||||
|
|
|
@ -21,6 +21,7 @@ cfg_if! { if #[cfg(web_sys_unstable_apis)] {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
mod on_click_outside;
|
mod on_click_outside;
|
||||||
|
mod use_to_string;
|
||||||
mod is_err;
|
mod is_err;
|
||||||
mod is_ok;
|
mod is_ok;
|
||||||
mod is_none;
|
mod is_none;
|
||||||
|
@ -60,6 +61,7 @@ mod watch_throttled;
|
||||||
mod whenever;
|
mod whenever;
|
||||||
|
|
||||||
pub use on_click_outside::*;
|
pub use on_click_outside::*;
|
||||||
|
pub use use_to_string::*;
|
||||||
pub use is_err::*;
|
pub use is_err::*;
|
||||||
pub use is_ok::*;
|
pub use is_ok::*;
|
||||||
pub use is_none::*;
|
pub use is_none::*;
|
||||||
|
|
23
src/use_to_string.rs
Normal file
23
src/use_to_string.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use crate::utils::use_derive_signal;
|
||||||
|
use leptos::*;
|
||||||
|
|
||||||
|
use_derive_signal!(
|
||||||
|
/// Reactive `ToString::to_string()`.
|
||||||
|
///
|
||||||
|
/// ## Usage
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// # use leptos::*;
|
||||||
|
/// # use leptos_use::use_to_string;
|
||||||
|
/// #
|
||||||
|
/// # #[component]
|
||||||
|
/// # fn Demo(cx: Scope) -> impl IntoView {
|
||||||
|
/// let (number, set_number) = create_signal(cx, 3.14_f64);
|
||||||
|
/// let str = use_to_string::<_, f64>(cx, number);
|
||||||
|
/// #
|
||||||
|
/// # view! { cx, }
|
||||||
|
/// # }
|
||||||
|
/// ```
|
||||||
|
use_to_string<T, T: ToString + 'static> -> String
|
||||||
|
|value| value.to_string()
|
||||||
|
);
|
Loading…
Add table
Reference in a new issue