ditto-lib / live.ditto / DittoPendingCursorOperation / observeAndSubscribe

observeAndSubscribe

fun observeAndSubscribe(eventHandler: (List<DittoDocument<T>>, DittoLiveQueryEvent<T>) -> Unit): DittoLiveQuery<T>
fun observeAndSubscribe(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 observeAndSubscribe. 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.