🌈 Create new beautiful Compose Gradients with our new wesite ->
Function

currentValueOf

Returns the current value of local at the position in the composition hierarchy of this modifier's attached layout node.

CompositionLocalConsumingModifierObserverNodeSample

@Sampled
@Composable
fun CompositionLocalConsumingModifierObserverNodeSample() {
    val LocalValue = compositionLocalOf { "abc123" }
    class ValueObserverModifierNode :
        Modifier.Node(), CompositionLocalConsumerModifierNode, ObserverModifierNode {
        private var observedValue: String? = null

        override fun onAttach() {
            onObservedReadsChanged()
        }

        override fun onDetach() {
            observedValue = null
        }

        override fun onObservedReadsChanged() {
            observeReads {
                observedValue = currentValueOf(LocalValue)
                // Do something with the new value
            }
        }
    }
}