Created
May 14, 2019 10:14
-
-
Save ShivamDev31/e311b9bb0d347af9346c6437b61573b3 to your computer and use it in GitHub Desktop.
saveName()
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
override fun saveName(name: String): Completable = prefSubject | |
.firstOrError() | |
.editSharedPreferences { | |
putString(KEY_NAME, name) | |
} | |
fun Single<SharedPreferences>.editSharedPreferences(batch: SharedPreferences.Editor.() -> Unit): Completable = | |
flatMapCompletable { | |
Completable.fromAction { | |
it.edit().also(batch).apply() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment