addChangeListener

expect open override fun addChangeListener(listener: QueryChangeListener): ListenerToken(source)

Adds a change listener for the changes that occur in the query results.

The changes will be delivered on the main thread for platforms that support it: Android, iOS, and macOS. Callbacks are on an arbitrary thread for the JVM, Linux, and Windows platform.

Return

An opaque listener token object for removing the listener.

Parameters

listener

The listener to post changes.


expect open override fun addChangeListener(context: CoroutineContext, listener: QueryChangeSuspendListener): ListenerToken(source)

Adds a change listener for the changes that occur in the query results with a CoroutineContext that will be used to launch coroutines the listener will be called on. Coroutines will be launched in a CoroutineScope that is canceled when the listener is removed.

Return

An opaque listener token object for removing the listener.

Parameters

context

coroutine context in which the listener will run

listener

The listener to post changes.


expect open override fun addChangeListener(scope: CoroutineScope, listener: QueryChangeSuspendListener)(source)

Adds a change listener for the changes that occur in the query results with a CoroutineScope that will be used to launch coroutines the listener will be called on. The listener is removed when the scope is canceled.

Return

An opaque listener token object for removing the listener.

Parameters

scope

coroutine scope in which the listener will run

listener

The listener to post changes.