Created
December 27, 2021 10:19
-
-
Save agustarc/74e1a6cfa82a5741d1ed88f9b15384ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suspend inline fun <T : Any> DataStore<Preferences>.storeValue(key: Preferences.Key<T>, value: T?) { | |
edit { preferences -> | |
if (value == null) { | |
preferences.remove(key) | |
} else { | |
preferences[key] = value | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment