ditto-lib / live.ditto / DittoPendingCursorOperation / observe

observe

fun observe(eventHandler: (List<DittoDocument<T>>, DittoLiveQueryEvent<T>) -> Unit): DittoLiveQuery<T>

Enables you to listen for changes that occur on a collection. The eventHandler closure will be called when local or remote changes are made to documents that match the query generated by the chain of operations that precedes the call to observe. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided eventHandler to be called when an update occurs.

fun observe(callback: DittoLiveQueryCallback<T>): DittoLiveQuery<T>

Enables you to listen for changes that occur on a collection. The eventHandler closure will be called when local or remote changes are made to documents that match the query generated by the chain of operations that precedes the call to observe. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided eventHandler to be called when an update occurs.