I have a settings screen where I am setting some values. When I set those values it gets saved in shared preferences and these values are needed in my request to the network
I've create a pure kotlin lib to do this - https://github.com/Jintin/PreferencesExtension
All we need to do is something like:
val preferenceLiveData = preference.liveData(MY_KEY)
preferenceLiveData.observe(this) {
// get update here
}
And sure the preferenceLiveData can be inside ViewModel and let Activity/Fragment observe it. Check out the example here: Activity, ViewModel