abstract fun asFlow(keyPaths: List<String>? = null): Flow<MapChange<K, V>>

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.

The change calculations will run on the thread represented by RealmConfiguration.Builder.notificationDispatcher.

The flow has an internal buffer of Channel.BUFFERED but if the consumer fails to consume the elements in a timely manner the coroutine scope will be cancelled with a CancellationException.


a flow representing changes to the dictionary.



An optional list of model class properties that defines when a change to objects inside the map will result in a change being emitted. For maps, keypaths are evaluated based on the values of the map. This means that keypaths are only supported for maps containing realm objects. Nested properties can be defined using a dotted syntax, e.g. Wildcards * can be be used to capture all properties at a given level, e.g. child.* or *.*. If no keypaths are provided, changes to all top-level properties and nested properties up to 4 levels down will trigger a change


if keypaths are invalid or the map does not contain realm objects.


if the stream produces changes faster than the consumer can consume them and results in a buffer overflow.