registerObserver

fun registerObserver(query: String, arguments: Map<String, Any?>? = null, changeHandler: DittoChangeHandler): DittoStoreObserver

Convenience method, same as registerObserver where signalNext is called automatically after the changeHandler finishes.

Since

4.5.0

Parameters

query

A string containing a valid query expressed in DQL.

arguments

A Map of values keyed by the placeholder name without the leading :. Example: ["mileage": 123].

changeHandler

A DittoChangeHandler lambda which will be invoked with the results as changes occur.


fun registerObserver(query: String, arguments: Map<String, Any?>? = null, changeHandler: DittoChangeHandlerWithNextSignal): DittoStoreObserver

Installs and returns a store observer for a query, configuring Ditto to trigger the passed in change handler whenever documents in the local store change such that the result of the matching query changes. The passed in query must be a SELECT query, otherwise a StoreError with QueryNotSupported reason is thrown.

Return

An active DittoStoreObserver for the given query and arguments. You'll have to keep it to be able to cancel the observation by close()-ing it. Otherwise it will remain active until the owning Ditto instance goes out of scope.

Since

4.5.0

Parameters

query

A string containing a valid query expressed in DQL.

arguments

A Map of values keyed by the placeholder name without the leading :. Example: ["mileage": 123].

changeHandler

A DittoChangeHandlerWithNextSignal lambda which will be invoked with the results as changes occur.

Throws