Skip to content

Instantly share code, notes, and snippets.

@ntngel1
Created June 4, 2019 13:49
Show Gist options
  • Save ntngel1/8ec9b1be7e6915f5f6fbb6eb56f5ef25 to your computer and use it in GitHub Desktop.
Save ntngel1/8ec9b1be7e6915f5f6fbb6eb56f5ef25 to your computer and use it in GitHub Desktop.
//
// просто берем параметры и подставляем в запрос realm'а
// нейминг здесь корявый, но он берется из Api дока, так что тут уже не наша сторона
override fun deletePhotoItem(id: String) = Completable.create { emitter ->
realm.executeTransaction { realm ->
val photo = realm.where(RealmPhotoEntity::class.java)
.equalTo("id", id)
.findFirst()
if (photo != null) {
photo.deleteFromRealm()
emitter.onSuccess(photo)
} else {
emitter.onError(Exception("Can't found PhotoEntity with parameters: id: String = $id"))
}
}
}.subscribeOn(scheduler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment