pub struct ElementMaybeSignal<T: 'static> { /* private fields */ }Expand description
Used as an argument type to make it easily possible to pass either
- a
&strfor example “div > p.some-class”, - a
web_syselement that implementsE(for exampleEventTarget,ElementorHtmlElement), - an
Option<T>whereTis the web_sys element, - a
Signal<T>,RwSignal<T>,ReadSignal<T>orMemo<T>whereTis the web_sys element or a String, - a
Signal<Option<T>>whereTis the web_sys element, - a
Signal<SendWrapper<T>>whereTis the web_sys element, - a
NodeRef
into a function. Used for example in crate::use_event_listener.
let test = "div > p.some-class";
use_element_size(&test); // &str
use_element_size(document().body()); // Option<web_sys::Element>
use_element_size(document().body().unwrap()); // web_sys::Element
let (string_signal, _set_string_signal) = signal("div > p.some-class".to_string());
use_element_size(string_signal); // Signal<String>
let (el_signal, _set_el_signal) = signal(
Some(SendWrapper::new(
document().query_selector("div > p.some-class").unwrap().unwrap()
))
);
use_element_size(el_signal); // Signal<Option<SendWrapper<web_sys::Element>>>
let (el_signal_send_wrapper, _set_el_signal_send_wrapper) = signal(
SendWrapper::new(
document().query_selector("div > p.some-class").unwrap().unwrap()
)
);
use_element_size(el_signal_send_wrapper); // Signal<SendWrapper<web_sys::Element>>
let el = NodeRef::<Div>::new();
use_element_size(el); // NodeRef
Trait Implementations§
Source§impl<T> Clone for ElementMaybeSignal<T>
impl<T> Clone for ElementMaybeSignal<T>
Source§impl<T> Default for ElementMaybeSignal<T>
impl<T> Default for ElementMaybeSignal<T>
Source§impl<T> DefinedAt for ElementMaybeSignal<T>
impl<T> DefinedAt for ElementMaybeSignal<T>
Source§fn defined_at(&self) -> Option<&'static Location<'static>>
fn defined_at(&self) -> Option<&'static Location<'static>>
Returns the location at which the signal was defined. This is usually simply
None in
release mode.Source§impl<T> ReadUntracked for ElementMaybeSignal<T>
impl<T> ReadUntracked for ElementMaybeSignal<T>
Source§type Value = ReadGuard<Option<SendWrapper<T>>, SignalReadGuard<Option<SendWrapper<T>>, SyncStorage>>
type Value = ReadGuard<Option<SendWrapper<T>>, SignalReadGuard<Option<SendWrapper<T>>, SyncStorage>>
The guard type that will be returned, which can be dereferenced to the value.
Source§fn try_read_untracked(&self) -> Option<Self::Value>
fn try_read_untracked(&self) -> Option<Self::Value>
Returns the guard, or
None if the signal has already been disposed.Source§fn read_untracked(&self) -> Self::Value
fn read_untracked(&self) -> Self::Value
Returns the guard. Read more
Source§fn custom_try_read(&self) -> Option<Option<Self::Value>>
fn custom_try_read(&self) -> Option<Option<Self::Value>>
This is a backdoor to allow overriding the
Read::try_read implementation despite it being auto implemented. Read moreSource§impl<T> Track for ElementMaybeSignal<T>
impl<T> Track for ElementMaybeSignal<T>
impl<T> Copy for ElementMaybeSignal<T>
Auto Trait Implementations§
impl<T> Freeze for ElementMaybeSignal<T>
impl<T> RefUnwindSafe for ElementMaybeSignal<T>
impl<T> Send for ElementMaybeSignal<T>
impl<T> Sync for ElementMaybeSignal<T>
impl<T> Unpin for ElementMaybeSignal<T>
impl<T> UnwindSafe for ElementMaybeSignal<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<El, T, Marker> IntoElementMaybeSignal<T, Marker> for Elwhere
El: IntoElementMaybeSignalType<T, Marker>,
impl<El, T, Marker> IntoElementMaybeSignal<T, Marker> for Elwhere
El: IntoElementMaybeSignalType<T, Marker>,
fn into_element_maybe_signal(self) -> ElementMaybeSignal<T>
Source§impl<T, Js> IntoElementMaybeSignalType<T, Element> for Js
impl<T, Js> IntoElementMaybeSignalType<T, Element> for Js
fn into_element_maybe_signal_type(self) -> ElementMaybeSignalType<T>
Source§impl<T, V, E> IntoElementMaybeSignalType<T, OptionSendWrapperSignalMarker> for V
impl<T, V, E> IntoElementMaybeSignalType<T, OptionSendWrapperSignalMarker> for V
fn into_element_maybe_signal_type(self) -> ElementMaybeSignalType<T>
Source§impl<T, V, E> IntoElementMaybeSignalType<T, OptionSignalMarker> for V
impl<T, V, E> IntoElementMaybeSignalType<T, OptionSignalMarker> for V
fn into_element_maybe_signal_type(self) -> ElementMaybeSignalType<T>
Source§impl<El, T, Marker> IntoElementsMaybeSignal<T, Marker> for Elwhere
El: IntoElementsMaybeSignalType<T, Marker>,
impl<El, T, Marker> IntoElementsMaybeSignal<T, Marker> for Elwhere
El: IntoElementsMaybeSignalType<T, Marker>,
fn into_elements_maybe_signal(self) -> ElementsMaybeSignal<T>
Source§impl<T, Js> IntoElementsMaybeSignalType<T, Element> for Js
impl<T, Js> IntoElementsMaybeSignalType<T, Element> for Js
fn into_elements_maybe_signal_type(self) -> ElementsMaybeSignalType<T>
Source§impl<T, Js, C, G> IntoElementsMaybeSignalType<T, SignalVecMarker> for G
impl<T, Js, C, G> IntoElementsMaybeSignalType<T, SignalVecMarker> for G
fn into_elements_maybe_signal_type(self) -> ElementsMaybeSignalType<T>
Source§impl<T, Js, C, G> IntoElementsMaybeSignalType<T, SignalVecSendWrapperMarker> for Gwhere
T: From<Js> + Clone,
G: Get<Value = C> + Send + Sync + 'static,
C: IntoIterator<Item = SendWrapper<Js>>,
impl<T, Js, C, G> IntoElementsMaybeSignalType<T, SignalVecSendWrapperMarker> for Gwhere
T: From<Js> + Clone,
G: Get<Value = C> + Send + Sync + 'static,
C: IntoIterator<Item = SendWrapper<Js>>,
fn into_elements_maybe_signal_type(self) -> ElementsMaybeSignalType<T>
Source§impl<T, S> IntoOptionGetter<T, SignalMarker> for S
impl<T, S> IntoOptionGetter<T, SignalMarker> for S
Source§fn into_option_getter(self) -> OptionGetter<T>
fn into_option_getter(self) -> OptionGetter<T>
Converts the given value into an
OptionGetter.Source§impl<T> Read for Twhere
T: Track + ReadUntracked,
impl<T> Read for Twhere
T: Track + ReadUntracked,
Source§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.
Source§impl<T> With for Twhere
T: Read,
impl<T> With for Twhere
T: Read,
Source§type Value = <<T as Read>::Value as Deref>::Target
type Value = <<T as Read>::Value as Deref>::Target
The type of the value contained in the signal.
Source§impl<T> WithUntracked for Twhere
T: DefinedAt + ReadUntracked,
impl<T> WithUntracked for Twhere
T: DefinedAt + ReadUntracked,
Source§type Value = <<T as ReadUntracked>::Value as Deref>::Target
type Value = <<T as ReadUntracked>::Value as Deref>::Target
The type of the value contained in the signal.
Source§fn try_with_untracked<U>(
&self,
fun: impl FnOnce(&<T as WithUntracked>::Value) -> U,
) -> Option<U>
fn try_with_untracked<U>( &self, fun: impl FnOnce(&<T as WithUntracked>::Value) -> U, ) -> Option<U>
Applies the closure to the value, and returns the result,
or
None if the signal has already been disposed.