Kotlin Flow version of rx-preferences -- Coroutines support for Android SharedPreferences
The key
and defaultValue
of a preference are now public and part of the Preference
interface https://github.com/tfcporciuncula/flow-preferences/commit/046c7342bbb025b9c71bf6454650c8c3d665f709
There's two (small) breaking changes:
ObjectPreference
doesn't support nullables anymore. If you were taking advantage of that, you can switch to NullableObjectPreference
by calling flowSharedPreferences.getNullableObject()
.Serializer
interface isn't defined within ObjectPreference
anymore, since ObjectPreference
is internal
now. Instead, it's a standalone interface with no particular namespace.compileSdk
to 30
https://github.com/tfcporciuncula/flow-preferences/commit/e7ce4637ce39d2799b1d329f56c86dbdbb95648b
This last point comes with an important behavior change. Starting on Android R, onSharedPreferenceChanged()
is triggered when clear()
is called, so the library has been updated to notify subscribers when a clear
happens. This will only happen if you're targeting Android R and the device is running Android R. You can observe the new behavior running the sample on an Android R device.
TL;DR: starting from this version, subscribers will be notified when clear()
is called on Android R+.
@JvmOverloads
to allow Java clients to take advantage of default values when creating preferences https://github.com/tfcporciuncula/flow-preferences/commit/20cfcebbb70948f6fa80fff9c576bea4271b520f
CoroutineContext
to be passed when creating a new preference, so clients can control where setAndCommit()
and deleteAndCommit()
will run https://github.com/tfcporciuncula/flow-preferences/pull/3
isNotSet()
as part of the preference API https://github.com/tfcporciuncula/flow-preferences/commit/2308dc2f13510b4ff8989e02a1e76f7c5b8066e8
Initial release.