Package dev.arunkumar.compass

Types

RealmBlock
Link copied to clipboard
typealias RealmBlock = (realm: Realm) -> Unit

Type representing a lambda with Realm as the parameter.

RealmFunction
Link copied to clipboard
typealias RealmFunction<T> = (realm: Realm) -> T

Type representing a lambda with Realm as the parameter returning type T.

RealmModelTransform
Link copied to clipboard
typealias RealmModelTransform<T, R> = Realm.(T) -> R

Type representing a lambda with the Realm as the receiver and RealmModel represented by T as the parameter and returning the computation as R.

Use RealmModelTransform to convert a managed RealmModel to type R. R can be any type but usually it is a non managed RealmModel instance or a mapped object derived from managed RealmModel.

RealmQueryBuilder
Link copied to clipboard
typealias RealmQueryBuilder<T> = Realm.() -> RealmQuery<T>

A type representing a lambda with Realm as the receiver returning RealmQuery of RealmModel

Use RealmQueryBuilder to construct RealmQuery instances. Various extensions are implemented on RealmQueryBuilder as a thread-safe alternative to RealmQuery methods.

RealmReceiver
Link copied to clipboard
typealias RealmReceiver = Realm.() -> Unit

Type representing a lambda with Realm as the receiver.

Functions

asFlow
Link copied to clipboard
fun <T : RealmModel> RealmQueryBuilder<T>.asFlow(dispatcher: RealmDispatcherProvider = { RealmDispatcher() }): Flow<List<T>>
Returns a Flow of list of R generated using transform on the RealmModel instances satisfying the current RealmQuery.
fun <T : RealmModel, R> RealmQueryBuilder<T>.asFlow(dispatcher: RealmDispatcherProvider = { RealmDispatcher() }, transform: RealmModelTransform<T, R>): Flow<List<R>>
Returns a Flow of list of R generated using transform on the RealmModel instances satisfying the current RealmQuery.
DefaultRealm
Link copied to clipboard
inline fun DefaultRealm(): Realm
Acquires a new instance of Realm using Realm.getDefaultInstance.
getAll
Link copied to clipboard
fun <T : RealmModel> RealmQueryBuilder<T>.getAll(): List<T>
Returns a List of RealmModel represented by T matching the RealmQuery produced by this builder.
Realm
Link copied to clipboard
inline fun Realm(block: RealmBlock)
Acquires an instance of current default Realm, runs the block with realm as the param.
RealmCopyTransform
Link copied to clipboard
fun <T : RealmModel, R> RealmCopyTransform(): RealmModelTransform<T, R>
A RealmModelTransform implementation that simply copies the managed RealmModel instance to a non managed one using Realm.copyFromRealm.
RealmFunction
Link copied to clipboard
inline fun <T> RealmFunction(block: RealmFunction<T>): T
Acquires an instance of current default Realm, runs the given block with the realm and returns the result.
RealmQuery
Link copied to clipboard
fun <T : RealmModel> RealmQuery(builder: RealmQueryBuilder<T>): RealmQueryBuilder<T>
Construct a RealmQueryBuilder instance.
RealmTransaction
Link copied to clipboard
inline fun RealmTransaction(noinline block: RealmReceiver)
Acquires an instance of current default Realm, runs the a RealmTransaction with the realm as the receiver in block.
toRealmList
Link copied to clipboard
inline fun <T : RealmModel> Collection<T>.toRealmList(): RealmList<T>
Converts a collection to non managed io.realm.RealmResults instance.
transact
Link copied to clipboard
inline fun Realm.transact(crossinline block: RealmReceiver)
Runs block with Realm as the receiver inside a Realm.executeTransaction block.