T
- The live object being returned
(Realm
, DynamicRealm
, RealmObject
, RealmResults
, DynamicRealmObject
or your model implementing RealmModel
)public interface RealmChangeListener<T>
Realm
, RealmResults
or RealmObject
to receive a notification about updates.
When registered against a Realm
you'll get notified when a Realm instance has been updated.
Register against a RealmResults
or RealmObject
to only get notified about changes to them.
Realm instances on a thread without an Looper
(almost all background threads) don't get updated
automatically, but have to call BaseRealm.refresh()
manually. This will in turn trigger the RealmChangeListener
for that background thread.
All RealmObject
and RealmResults
will automatically contain their new values when
the onChange(Object)
method is called. Normally this means that it isn't necessary to query again for those
objects, but just invalidate any UI elements that are using them. If there is a chance that a object has been been
deleted, it can be verified by using RealmObject.isValid()
.
Realm.addChangeListener(RealmChangeListener)
,
BaseRealm.removeAllChangeListeners()
,
BaseRealm.removeChangeListener(RealmChangeListener)
Modifier and Type | Method and Description |
---|---|
void |
onChange(T element)
Called when a transaction is committed.
|
void onChange(T element)