Let's assume we have an app that has some settings and one of the settings is a switch button which changes the color (or font size, whatever) of the
Text
. The setting is stored in
DataStore
.
Only in certain screens and at specific places the
Text
must change based on the settings.
So imagine we wrap this
Text
in a composable named
DynamicText
.
The
DynamicText
can be found in ScreenA, ScreenB and ScreenD.
One way I assume to achieve this is to observe the setting in the viewmodels of those screens and update
DynamicText
.
However is there any other way to achieve this? I imagine something like a singleton class "Observer" that holds the value of the setting and we can somehow pass it to
DynamicText
, is that possible?
Or any other way?