Function

currentValueOf

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

CompositionLocalConsumingModifierObserverNodeSample

@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
            }
        }
    }
}