pub struct StaticCompositionLocal<T: Clone + 'static> { /* private fields */ }Expand description
A composition local for values that rarely change, as Jetpack Compose’s
staticCompositionLocalOf. A read of .current() subscribes nothing, so
it costs less than a read of a CompositionLocal. In return, a
provider whose value changes recomposes everything it provides to, not
only the readers: every composable call under it runs its body, and
every subcomposition under it composes again the same way.
Implementations§
Source§impl<T: Clone + 'static> StaticCompositionLocal<T>
impl<T: Clone + 'static> StaticCompositionLocal<T>
Sourcepub fn provides(&self, value: T) -> ProvidedValue
pub fn provides(&self, value: T) -> ProvidedValue
Pairs this local with value for use in CompositionLocalProvider. When a later
composition provides a different value, everything under the provider recomposes.
Sourcepub fn provides_computed(
&self,
compute: impl Fn(&CompositionLocalAccessorScope) -> T + 'static,
) -> ProvidedValue
pub fn provides_computed( &self, compute: impl Fn(&CompositionLocalAccessorScope) -> T + 'static, ) -> ProvidedValue
Pairs this local with compute, which runs at each read of the local
under the provider and reads other locals there through its scope.
Each composition of the provider gives a new computation, which
recomposes everything under it. Compose’s providesComputed.
Sourcepub fn current(&self) -> T
pub fn current(&self) -> T
Returns the value from the innermost enclosing provider, or the default value when none is in scope. Must be called during composition. A read subscribes nothing.
Sourcepub fn default_value(&self) -> T
pub fn default_value(&self) -> T
Returns the value that current gives where no provider is in scope.
Trait Implementations§
impl<T: Clone + 'static> Eq for StaticCompositionLocal<T>
Source§impl<T: Clone + 'static> PartialEq for StaticCompositionLocal<T>
impl<T: Clone + 'static> PartialEq for StaticCompositionLocal<T>
Source§impl<T: Clone + 'static> ReadableCompositionLocal<T> for StaticCompositionLocal<T>
impl<T: Clone + 'static> ReadableCompositionLocal<T> for StaticCompositionLocal<T>
Source§fn read_current(&self) -> T
fn read_current(&self) -> T
current gives it.