Skip to content

Instantly share code, notes, and snippets.

View ricardoAntolin's full-sized avatar
🏠
Working from home

Ricardo Antolin ricardoAntolin

🏠
Working from home
View GitHub Profile
View Mapper
fun RLProductEntity.asDataEntity(): ProductEntity = ProductEntity(code, name, price)
fun List<RLProductEntity>.asDataEntity(): List<ProductEntity> = map { it.asDataEntity() }
fun Flowable<List<RLProductEntity>>.asDataEntity() = this.map { it.asDataEntity() }
fun ProductEntity.asRealmEntity(): RLProductEntity = RLProductEntity(code, name, price)
fun List<ProductEntity>.asRealmEntity(): List<RLProductEntity> = map { it.asRealmEntity() }
View RealmService
import io.reactivex.Completable
import io.reactivex.Flowable
import io.realm.Realm
import io.realm.RealmObject
import io.realm.RealmQuery
import io.realm.RealmResults
abstract class RealmService<T : RealmObject, ID> {
inline fun <reified T : RealmObject> findByPrimaryKey(id: ID): Flowable<T> =
View RealmExtensions
import android.os.HandlerThread
import android.os.Looper
import android.os.Process
import androidx.annotation.VisibleForTesting
import io.reactivex.Completable
import io.reactivex.Flowable
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.realm.Realm
import io.realm.RealmModel