Created
December 27, 2021 10:17
-
-
Save agustarc/c6780edf39e7b0252edcd93908037142 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
public suspend fun DataStore<Preferences>.edit( | |
transform: suspend (MutablePreferences) -> Unit | |
): Preferences { | |
return this.updateData { | |
// It's safe to return MutablePreferences since we freeze it in | |
// PreferencesDataStore.updateData() | |
it.toMutablePreferences().apply { transform(this) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment