pub struct Global<T, R = T> { /* private fields */ }prelude only.Expand description
A lazy value that is created once per application and can be accessed from anywhere in that application
Implementations§
Source§impl<T, R> Global<T, R>
impl<T, R> Global<T, R>
Source§impl<T, R> Global<T, R>where
T: Clone + InitializeFromFunction<R>,
impl<T, R> Global<T, R>where
T: Clone + InitializeFromFunction<R>,
Sourcepub const fn with_name(
constructor: fn() -> R,
key: &'static str,
) -> Global<T, R>
pub const fn with_name( constructor: fn() -> R, key: &'static str, ) -> Global<T, R>
Create this global signal with a specific key. This is useful for ensuring that the signal is unique across the application and accessible from outside the application too.
Sourcepub const fn with_location(
constructor: fn() -> R,
file: &'static str,
line: u32,
column: u32,
index: usize,
) -> Global<T, R>
pub const fn with_location( constructor: fn() -> R, file: &'static str, line: u32, column: u32, index: usize, ) -> Global<T, R>
Create this global signal with a specific key. This is useful for ensuring that the signal is unique across the application and accessible from outside the application too.
Sourcepub fn resolve(&self) -> Twhere
T: 'static,
pub fn resolve(&self) -> Twhere
T: 'static,
Resolve the global value. This will try to get the existing value from the current virtual dom, and if it doesn’t exist, it will create a new one.
Sourcepub fn origin_scope(&self) -> ScopeId
pub fn origin_scope(&self) -> ScopeId
Get the scope the signal was created in.
Trait Implementations§
Source§impl<T, R> Deref for Global<T, R>
Allow calling a signal with signal() syntax
impl<T, R> Deref for Global<T, R>
Allow calling a signal with signal() syntax
Currently only limited to copy types, though could probably specialize for string/arc/rc
Source§impl<T, R> From<Global<T, R>> for ReadSignal<R>where
T: Readable<Target = R, Storage = UnsyncStorage> + InitializeFromFunction<R> + Clone + 'static,
R: 'static,
impl<T, R> From<Global<T, R>> for ReadSignal<R>where
T: Readable<Target = R, Storage = UnsyncStorage> + InitializeFromFunction<R> + Clone + 'static,
R: 'static,
Source§fn from(value: Global<T, R>) -> ReadSignal<R>
fn from(value: Global<T, R>) -> ReadSignal<R>
Source§impl<T, R> From<Global<T, R>> for WriteSignal<R>where
T: Writable<Target = R, Storage = UnsyncStorage> + InitializeFromFunction<R> + Clone + 'static,
R: 'static,
impl<T, R> From<Global<T, R>> for WriteSignal<R>where
T: Writable<Target = R, Storage = UnsyncStorage> + InitializeFromFunction<R> + Clone + 'static,
R: 'static,
Source§fn from(value: Global<T, R>) -> WriteSignal<R>
fn from(value: Global<T, R>) -> WriteSignal<R>
Source§impl<T, R> Readable for Global<T, R>
impl<T, R> Readable for Global<T, R>
Source§fn try_read_unchecked(
&self,
) -> Result<<<Global<T, R> as Readable>::Storage as AnyStorage>::Ref<'static, <Global<T, R> as Readable>::Target>, BorrowError>where
R: 'static,
fn try_read_unchecked(
&self,
) -> Result<<<Global<T, R> as Readable>::Storage as AnyStorage>::Ref<'static, <Global<T, R> as Readable>::Target>, BorrowError>where
R: 'static,
Source§fn try_peek_unchecked(
&self,
) -> Result<<<Global<T, R> as Readable>::Storage as AnyStorage>::Ref<'static, <Global<T, R> as Readable>::Target>, BorrowError>where
R: 'static,
fn try_peek_unchecked(
&self,
) -> Result<<<Global<T, R> as Readable>::Storage as AnyStorage>::Ref<'static, <Global<T, R> as Readable>::Target>, BorrowError>where
R: 'static,
Source§fn subscribers(&self) -> Subscriberswhere
R: 'static,
fn subscribers(&self) -> Subscriberswhere
R: 'static,
Source§impl<T, R> Writable for Global<T, R>
impl<T, R> Writable for Global<T, R>
Source§type WriteMetadata = <T as Writable>::WriteMetadata
type WriteMetadata = <T as Writable>::WriteMetadata
Source§fn try_write_unchecked(
&self,
) -> Result<WriteLock<'static, <Global<T, R> as Readable>::Target, <Global<T, R> as Readable>::Storage, <Global<T, R> as Writable>::WriteMetadata>, BorrowMutError>
fn try_write_unchecked( &self, ) -> Result<WriteLock<'static, <Global<T, R> as Readable>::Target, <Global<T, R> as Readable>::Storage, <Global<T, R> as Writable>::WriteMetadata>, BorrowMutError>
Auto Trait Implementations§
impl<T, R> Freeze for Global<T, R>
impl<T, R> RefUnwindSafe for Global<T, R>
impl<T, R> Send for Global<T, R>
impl<T, R> Sync for Global<T, R>
impl<T, R> Unpin for Global<T, R>
impl<T, R> UnwindSafe for Global<T, R>
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R> ReadableBoxExt for R
impl<R> ReadableBoxExt for R
Source§impl<R> ReadableExt for R
impl<R> ReadableExt for R
Source§fn read(&self) -> <Self::Storage as AnyStorage>::Ref<'_, Self::Target>where
Self::Target: 'static,
fn read(&self) -> <Self::Storage as AnyStorage>::Ref<'_, Self::Target>where
Self::Target: 'static,
Source§fn try_read(
&self,
) -> Result<<Self::Storage as AnyStorage>::Ref<'_, Self::Target>, BorrowError>where
Self::Target: 'static,
fn try_read(
&self,
) -> Result<<Self::Storage as AnyStorage>::Ref<'_, Self::Target>, BorrowError>where
Self::Target: 'static,
Source§fn read_unchecked(
&self,
) -> <Self::Storage as AnyStorage>::Ref<'static, Self::Target>where
Self::Target: 'static,
fn read_unchecked(
&self,
) -> <Self::Storage as AnyStorage>::Ref<'static, Self::Target>where
Self::Target: 'static,
Source§fn peek(&self) -> <Self::Storage as AnyStorage>::Ref<'_, Self::Target>where
Self::Target: 'static,
fn peek(&self) -> <Self::Storage as AnyStorage>::Ref<'_, Self::Target>where
Self::Target: 'static,
Source§fn try_peek(
&self,
) -> Result<<Self::Storage as AnyStorage>::Ref<'_, Self::Target>, BorrowError>where
Self::Target: 'static,
fn try_peek(
&self,
) -> Result<<Self::Storage as AnyStorage>::Ref<'_, Self::Target>, BorrowError>where
Self::Target: 'static,
Source§fn peek_unchecked(
&self,
) -> <Self::Storage as AnyStorage>::Ref<'static, Self::Target>where
Self::Target: 'static,
fn peek_unchecked(
&self,
) -> <Self::Storage as AnyStorage>::Ref<'static, Self::Target>where
Self::Target: 'static,
Source§fn map<F, O>(self, f: F) -> MappedSignal<O, Self, F>
fn map<F, O>(self, f: F) -> MappedSignal<O, Self, F>
Source§fn cloned(&self) -> Self::Target
fn cloned(&self) -> Self::Target
Source§fn with<O>(&self, f: impl FnOnce(&Self::Target) -> O) -> Owhere
Self::Target: 'static,
fn with<O>(&self, f: impl FnOnce(&Self::Target) -> O) -> Owhere
Self::Target: 'static,
Source§impl<K, V, H, R> ReadableHashMapExt<K, V, H> for R
impl<K, V, H, R> ReadableHashMapExt<K, V, H> for R
Source§impl<V, H, R> ReadableHashSetExt<V, H> for R
impl<V, H, R> ReadableHashSetExt<V, H> for R
Source§impl<T, R> ReadableOptionExt<T> for R
impl<T, R> ReadableOptionExt<T> for R
Source§impl<T, E, R> ReadableResultExt<T, E> for R
impl<T, E, R> ReadableResultExt<T, E> for R
Source§fn unwrap(&self) -> Twhere
T: Clone + 'static,
E: 'static,
fn unwrap(&self) -> Twhere
T: Clone + 'static,
E: 'static,
Source§fn as_ref(
&self,
) -> Result<<Self::Storage as AnyStorage>::Ref<'_, T>, <Self::Storage as AnyStorage>::Ref<'_, E>>where
T: 'static,
E: 'static,
fn as_ref(
&self,
) -> Result<<Self::Storage as AnyStorage>::Ref<'_, T>, <Self::Storage as AnyStorage>::Ref<'_, E>>where
T: 'static,
E: 'static,
Source§impl<W> ReadableStringExt for W
impl<W> ReadableStringExt for W
Source§impl<T, R> ReadableVecExt<T> for R
impl<T, R> ReadableVecExt<T> for R
Source§fn first(&self) -> Option<<Self::Storage as AnyStorage>::Ref<'_, T>>where
T: 'static,
fn first(&self) -> Option<<Self::Storage as AnyStorage>::Ref<'_, T>>where
T: 'static,
Source§fn last(&self) -> Option<<Self::Storage as AnyStorage>::Ref<'_, T>>where
T: 'static,
fn last(&self) -> Option<<Self::Storage as AnyStorage>::Ref<'_, T>>where
T: 'static,
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.