Open JamalMulla opened 2 years ago
I would be interested in using this. Do you have any thoughts on how this might be done? Do you plan to use multiplatform-settings?
Hi. I haven't looked into it at all as I have no experience with multiplatform. However that does look very interesting and could certainly be used for saving the values. If I do ever get time to come back to this I'll keep it in mind. I'm also open to PRs so if you want to work on it, feel free. Thanks
I'm new to multiplatform too and am just learnign about flowx, coroutines, scopes, etc...
Do you have any tips on how we might do this? For example, would you replace DataStore with Settings
from multiplatform-settings? or wrap them in a generic object?
I created a couple of basic Prefs composables based on your code and I replaced the datastore with Settings from multiplatform-settings.
To set a preference: settings[key] = value
.
To watch a preference:
val selectedValue = (settings as? ObservableSettings)
?.toFlowSettings(Dispatchers.Main)
?.getStringOrNullFlow(key)
?.collectAsState(default)
That seems reasonable. But yeah I'm not sure how the architecture would have to change to accommodate this. I'd have to look into it some more but don't have the time for it currently.
I thought about this a bit more. One possibility is to add another PrefsScreen
composable function which takes the Multiplatform-Settings' ObservableSettings
object instead of the DataStore
object. Then inside PrefsScreen
we wrap the DataStore
or ObservableSettings
in a generic class to get and set values.
I would be interested in using this. Do you have any thoughts on how this might be done? Do you plan to use multiplatform-settings?