Skip to content

Instantly share code, notes, and snippets.

@ShivamDev31
Created May 14, 2019 10:14
Show Gist options
  • Save ShivamDev31/e311b9bb0d347af9346c6437b61573b3 to your computer and use it in GitHub Desktop.
Save ShivamDev31/e311b9bb0d347af9346c6437b61573b3 to your computer and use it in GitHub Desktop.
saveName()
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