abstract fun asFlow(keyPath: List<String>? = null): Flow<ResultsChange<T>>

Finds all objects that fulfill the query conditions and returns them asynchronously as a Flow.

Once subscribed the flow will emit a InitialResults event and then a UpdatedResults on any change to the objects represented by the query backing the RealmResults. The flow will continue running indefinitely until canceled.

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.

It is not allowed to call asFlow on queries generated from a MutableRealm.


a flow representing changes to the RealmResults resulting from running this query.



An optional list of properties that defines when a change to the object will result in a change being emitted. Nested properties can be defined using a dotted syntax, e.g. If no keypaths are provided, changes to all top-level properties and nested properties 4 levels down will trigger a change.


if an invalid keypath is provided.