pub struct CompositionLocal<T: Clone + 'static> { /* private fields */ }Expand description
A value that composables read from their surroundings without passing it as a parameter, as
Jetpack Compose’s compositionLocalOf. A scope that reads current recomposes when the
provided value changes.
Implementations§
Source§impl<T: Clone + 'static> CompositionLocal<T>
impl<T: Clone + 'static> CompositionLocal<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, the scopes that read the local recompose.
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.
A reader recomposes when a local the computation read changes, and
when a later composition of the provider gives a new computation.
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. The reading scope recomposes when the provided value changes.
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 CompositionLocal<T>
Source§impl<T: Clone + 'static> PartialEq for CompositionLocal<T>
impl<T: Clone + 'static> PartialEq for CompositionLocal<T>
Source§impl<T: Clone + 'static> ReadableCompositionLocal<T> for CompositionLocal<T>
impl<T: Clone + 'static> ReadableCompositionLocal<T> for CompositionLocal<T>
Source§fn read_current(&self) -> T
fn read_current(&self) -> T
current gives it.