RealmChange

interface RealmChange<R : BaseRealm>

This sealed interface describe the possible changes that can be observed to a Realm.

The specific states are represented by the subclasses InitialRealm and UpdatedRealm.

Changes can thus be consumed in a number of ways:

// Variant 1: Switch on the sealed interface
realm.asFlow()
.collect { realmChange: RealmChange ->
when(realmChange) {
is InitialRealm -> setInitialState(realmChange.realm)
is UpdatedRealm -> setUpdatedState(realmChange.realm)
}
}


// Variant 2: Just pass on the realm
realm.asFlow()
.collect { realmChange: RealmChange ->
handleChange(realmChange.realm)
}

Inheritors

Properties

Link copied to clipboard
abstract val realm: R

Returns the realm instance that was affected by the change event.