asFlow

abstract fun asFlow(): 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.

Return

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