2023-05-29 01:52:03 +01:00
|
|
|
use leptos::*;
|
|
|
|
|
|
|
|
/// SSR compatibe `is_supported`
|
|
|
|
///
|
|
|
|
/// ## Usage
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// # use leptos::*;
|
|
|
|
/// # use leptos_use::use_supported;
|
|
|
|
/// # use wasm_bindgen::JsValue;
|
|
|
|
/// #
|
2023-07-27 18:06:36 +01:00
|
|
|
/// # pub fn Demo() -> impl IntoView {
|
2023-05-29 01:52:03 +01:00
|
|
|
/// let is_supported = use_supported(
|
|
|
|
/// || JsValue::from("getBattery").js_in(&window().navigator())
|
|
|
|
/// );
|
|
|
|
///
|
2023-06-21 13:09:00 +02:00
|
|
|
/// if is_supported.get() {
|
2023-05-29 01:52:03 +01:00
|
|
|
/// // do something
|
|
|
|
/// }
|
2023-07-27 18:06:36 +01:00
|
|
|
/// # view! { }
|
2023-05-29 01:52:03 +01:00
|
|
|
/// # }
|
|
|
|
/// ```
|
2023-07-27 18:06:36 +01:00
|
|
|
pub fn use_supported(callback: impl Fn() -> bool + 'static) -> Signal<bool> {
|
|
|
|
Signal::derive(callback)
|
2023-05-29 01:52:03 +01:00
|
|
|
}
|