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> UnsafeUnpin 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
impl<T> ErasedDestructor for Twhere
T: 'static,
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 more