Anyone here using Jetpack DataStore? When my fragm...
# android
Anyone here using Jetpack DataStore? When my fragment starts I want to load a value once. Right now I'm doing it like this, but it looks a bit awkward. Is this the correct approach? (this is inside
You can also use
instead of
thank you
However, I don't understand how this method works. Why do I have to return a boolean?
Use overload without lambda first() is a suspend function which awaits first value from flow and return it First with lambda is a way to filter values, so first value will be returned when dlpredicate returned true
isChecked = preferencesFlow.first().hideCompleted
thank you very much, that's awesome
works perfectly, thank you
and it looks less ugly
the only downside of this is that this crashes if the Flow is empty
I don't know if my Flow can be empty
it's from the Android Jetpack DataStore
i have to pass a default value when I read from DataStore, so I assume it will always have a value?
But isn't datastire always have value?
Or I may be wrong, you can use operator to return default value
I assume it always has a value
when I uninstall the app it has one on first start