Created
June 4, 2019 13:49
-
-
Save ntngel1/8ec9b1be7e6915f5f6fbb6eb56f5ef25 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
// | |
// просто берем параметры и подставляем в запрос 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