leptos_use/math/
use_not.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use leptos::*;

/// Reactive `NOT` condition.
///
/// ## Demo
///
/// [Link to Demo](https://github.com/Synphonyte/leptos-use/tree/main/examples/use_not)
///
/// ## Usage
///
/// ```
/// # use leptos::*;
/// # use leptos_use::math::use_not;
/// #
/// # #[component]
/// # fn Demo() -> impl IntoView {
/// let (a, set_a) = create_signal(true);
///
/// let not_a = use_not(a);
/// #
/// # view! { }
/// # }
/// ```
///
/// See also
///
/// - [`use_and`]
/// - [`use_or`]
///
// #[doc(cfg(feature = "math"))]
pub fn use_not<S>(a: S) -> Signal<bool>
where
    S: Into<MaybeSignal<bool>>,
{
    let a = a.into();
    Signal::derive(move || !a.get())
}