RealmDictionary
A RealmDictionary
is a specialization for RealmMaps whose keys are Strings
.
Similarly to RealmList or RealmSet, RealmMap
can operate in managed and unmanaged modes. In managed mode a RealmDictionary
persists all its contents in a Realm instance whereas unmanaged dictionaries are backed by an in-memory LinkedHashMap.
A managed dictionary can only be created by Realm and will automatically update its content whenever its underlying realm is updated. Managed dictionaries can only be accessed using the getter that points to a RealmDictionary
property of a managed RealmObject.
Unmanaged dictionaries can be created by calling realmDictionaryOf and may contain both managed and unmanaged RealmObjects. Unmanaged dictionaries can be added to a realm using the MutableRealm.copyToRealm function with an object containing an unmanaged dictionary.
A RealmDictionary
may contain any type of Realm primitive nullable and non-nullable values. RealmObjects and EmbeddedRealmObjects are also supported but must be declared nullable.
Parameters
the type of the values stored in this map
Functions
Observes changes to the RealmMap
. The Flow will emit InitialMap once subscribed, and then UpdatedMap on every change to the dictionary. The flow will continue running indefinitely until canceled or until the parent object is deleted.
Makes an unmanaged in-memory copy of the elements in a managed RealmDictionary. This is a deep copy that will copy all referenced objects.
Query the objects in a dictionary by filter
and arguments
. The query is launched against the output obtained from RealmDictionary.values. This means keys are not taken into consideration.
Instantiates an unmanaged RealmDictionary containing all the elements of the receiver dictionary represented by a Map of String to T pairs.