asFlow

abstract fun asFlow(): Flow<ListChange<E>>

Observes changes to the RealmList. The Flow will emit InitialList once subscribed, and then UpdatedList on every change to the list. 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.

Return

a flow representing changes to the list.

Throws

kotlinx.coroutines.CancellationException

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