2023-07-16 14:00:12 +01:00
|
|
|
use crate::utils::use_derive_signal;
|
|
|
|
use leptos::*;
|
|
|
|
|
|
|
|
use_derive_signal!(
|
|
|
|
/// Reactive `Option::is_none()`.
|
|
|
|
///
|
|
|
|
/// ## Usage
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// # use leptos::*;
|
|
|
|
/// # use leptos_use::is_none;
|
|
|
|
/// #
|
|
|
|
/// # #[component]
|
2023-07-27 18:06:36 +01:00
|
|
|
/// # fn Demo() -> impl IntoView {
|
2023-07-16 14:00:12 +01:00
|
|
|
/// let (example, set_example) = create_signal(
|
|
|
|
/// if js_sys::Math::random() < 0.5 { Some("Example") } else { None }
|
|
|
|
/// );
|
|
|
|
///
|
2023-07-27 18:06:36 +01:00
|
|
|
/// let is_empty = is_none(example);
|
2023-07-16 14:00:12 +01:00
|
|
|
/// #
|
2023-07-27 18:06:36 +01:00
|
|
|
/// # view! { }
|
2023-07-16 14:00:12 +01:00
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
is_none<Option<T>, T: 'static> -> bool
|
|
|
|
|value| value.is_none()
|
|
|
|
);
|